Initial commit: Add CodeIgniter 4 QC application with full MVC structure

- CodeIgniter 4 framework setup with SQL Server database config
- Models: Control, Test, Dept, Result, Daily/ Monthly entry models
- Controllers: Dashboard, Control, Test, Dept, Entry, Report, API endpoints
- Views: CRUD pages with modal dialogs, dashboard, reports
- Database: Migrations for control test and daily/monthly result tables
- Legacy v1 PHP application preserved in /v1 directory
- Documentation: AGENTS.md, VIEWS_RULES.md for development guidelines
This commit is contained in:
mahdahar 2026-01-14 16:49:27 +07:00
commit ff90e0eb29
174 changed files with 66312 additions and 0 deletions

126
.gitignore vendored Normal file
View File

@ -0,0 +1,126 @@
#-------------------------
# Operating Specific Junk Files
#-------------------------
# OS X
.DS_Store
.AppleDouble
.LSOverride
# OS X Thumbnails
._*
# Windows image file caches
Thumbs.db
ehthumbs.db
Desktop.ini
# Recycle Bin used on file shares
$RECYCLE.BIN/
# Windows Installer files
*.cab
*.msi
*.msm
*.msp
# Windows shortcuts
*.lnk
# Linux
*~
# KDE directory preferences
.directory
# Linux trash folder which might appear on any partition or disk
.Trash-*
#-------------------------
# Environment Files
#-------------------------
# These should never be under version control,
# as it poses a security risk.
.env
.vagrant
Vagrantfile
#-------------------------
# Temporary Files
#-------------------------
writable/cache/*
!writable/cache/index.html
writable/logs/*
!writable/logs/index.html
writable/session/*
!writable/session/index.html
writable/uploads/*
!writable/uploads/index.html
writable/debugbar/*
!writable/debugbar/index.html
php_errors.log
#-------------------------
# User Guide Temp Files
#-------------------------
user_guide_src/build/*
user_guide_src/cilexer/build/*
user_guide_src/cilexer/dist/*
user_guide_src/cilexer/pycilexer.egg-info/*
#-------------------------
# Test Files
#-------------------------
tests/coverage*
# Don't save phpunit under version control.
phpunit
#-------------------------
# Composer
#-------------------------
vendor/
#-------------------------
# IDE / Development Files
#-------------------------
# Modules Testing
_modules/*
# phpenv local config
.php-version
# Jetbrains editors (PHPStorm, etc)
.idea/
*.iml
# NetBeans
/nbproject/
/build/
/nbbuild/
/dist/
/nbdist/
/nbactions.xml
/nb-configuration.xml
/.nb-gradle/
# Sublime Text
*.tmlanguage.cache
*.tmPreferences.cache
*.stTheme.cache
*.sublime-workspace
*.sublime-project
.phpintel
/api/
# Visual Studio Code
.vscode/
/results/
/phpunit*.xml

340
AGENTS.md Normal file
View File

@ -0,0 +1,340 @@
# AGENTS.md - QC Application Development Guide
This document provides guidelines for agentic coding agents working on this PHP QC (Quality Control) application built with CodeIgniter 4.
## Project Overview
This is a CodeIgniter 4 PHP application using SQL Server database for quality control data management. The app handles control tests, daily/monthly entries, and reporting. Uses Tailwind CSS and Alpine.js for UI.
## Build/Lint/Test Commands
```bash
# PHP syntax check single file
php -l app/Controllers/Dashboard.php
# PHP syntax check all files recursively
find . -name "*.php" -exec php -l {} \; 2>&1 | grep -v "No syntax errors"
# Run all PHPUnit tests
./vendor/bin/phpunit
# Run single test class
./vendor/bin/phpunit tests/unit/HealthTest.php
# Run single test method
./vendor/bin/phpunit tests/unit/HealthTest.php --filter=testIsDefinedAppPath
# Run with coverage report
./vendor/bin/phpunit --coverage-html coverage/
# Start development server
php spark serve
```
## Code Style Guidelines
### General Principles
- Follow CodeIgniter 4 MVC patterns
- Maintain consistency with surrounding code
- Keep files focused (<200 lines preferred)
- Use clear, descriptive names
### PHP Style
- Use `<?php` opening tag (not `<?` short tags)
- Enable strict types: `declare(strict_types=1);` at top of PHP files
- Use strict comparison (`===`, `!==`) over loose comparison
- Use `elseif` (one word) not `else if`
- Use parentheses with control structures for single statements
- Use 4 spaces for indentation (not tabs)
- Return types and typed properties required for new code:
```php
public function index(): string
{
return view('layout', [...]);
}
```
### Naming Conventions
- Classes: `PascalCase` (e.g., `Dashboard`, `DictTestModel`)
- Methods/functions: `$camelCase` (e.g., `getWithDept`, `saveResult`)
- Variables: `$camelCase` (e.g., `$dictTestModel`, `$resultData`)
- Constants: `UPPER_SNAKE_CASE`
- Views: `lowercase_with_underscores` (e.g., `dashboard.php`, `test_index.php`)
- Routes: kebab-case URLs (e.g., `/test/edit/(:num)``/test/edit/1`)
### CodeIgniter 4 Patterns
**Controllers** extend `App\Controllers\BaseController`:
```php
namespace App\Controllers;
use App\Models\DictTestModel;
class Test extends BaseController
{
protected $dictTestModel;
public function __construct()
{
$this->dictTestModel = new DictTestModel();
}
public function index(): string
{
$data = [
'title' => 'Test Dictionary',
'tests' => $this->dictTestModel->findAll(),
];
return view('layout', [
'content' => view('test/index', $data),
'page_title' => 'Test Dictionary',
'active_menu' => 'test'
]);
}
}
```
**Models** extend `CodeIgniter\Model`:
```php
namespace App\Models;
use CodeIgniter\Model;
class TestModel extends Model
{
protected $table = 'dict_test';
protected $primaryKey = 'id';
protected $returnType = 'array';
protected $useSoftDeletes = false;
protected $allowedFields = ['deptid', 'name', 'unit', 'method'];
}
```
**Views** use PHP short tags `<?= ?>` for output:
```php
<div class="space-y-6">
<h1 class="text-2xl font-bold"><?= $title ?></h1>
<?php foreach ($tests as $test): ?>
<div><?= $test['name'] ?></div>
<?php endforeach; ?>
</div>
```
### Database Operations
- Configure connections in `app/Config/Database.php`
- Use CodeIgniter's Query Builder for queries
- Use parameterized queries to prevent SQL injection:
```php
$builder = $this->db->table('results');
$builder->select('*');
$builder->where('control_ref_id', $controlId);
$results = $builder->get()->getResultArray();
```
- For SQL Server, set `DBDriver` to `'SQLSRV'` in config
### Error Handling
- Use CodeIgniter's exception handling: `throw new \CodeIgniter\Exceptions\PageNotFoundException('Not found')`
- Return JSON responses for AJAX endpoints:
```php
return $this->response->setJSON(['success' => true, 'data' => $results]);
```
- Use `log_message('error', $message)` for logging
- Validate input with `$this->validate()` in controllers
### Frontend (Tailwind CSS + Alpine.js)
The layout already includes Tailwind via CDN and Alpine.js:
```html
<script src="https://cdn.tailwindcss.com"></script>
<script defer src="https://cdn.jsdelivr.net/npm/alpinejs@3.x.x/dist/cdn.min.js"></script>
```
**Common JavaScript (`public/js/app.js`):**
- Contains global `App` object with shared utilities
- Handles sidebar toggle functionality
- Provides `App.showToast()`, `App.confirmSave()`, `App.closeAllModals()`
- Initialize with `App.init()` on DOMContentLoaded
**Page-Specific Alpine.js:**
- Complex Alpine.js components should be defined inline in the view PHP file
- Use `x-data` with an object containing all properties and methods
- Example:
```html
<div x-data="{
property1: '',
property2: [],
init() {
// Initialization code
},
async loadData() {
// Fetch and handle data
App.showToast('Loaded successfully');
}
}">
<!-- Component markup -->
</div>
```
### File Organization
- Controllers: `app/Controllers/`
- Models: `app/Models/`
- Views: `app/Views/` (subfolders for modules: `entry/`, `test/`, `control/`, `report/`, `dept/`)
- Config: `app/Config/`
- Routes: `app/Config/Routes.php`
### Modal-based CRUD Pattern
All CRUD operations use a single modal dialog file (`dialog.php`) that handles both add and edit modes.
**File Naming:**
- Single dialog: `dialog.php` (no `_add` or `_edit` suffix)
**Controller Pattern:**
```php
class Dept extends BaseController
{
protected $dictDeptModel;
public function __construct()
{
$this->dictDeptModel = new DictDeptModel();
}
public function index(): string
{
$data = [
'title' => 'Department Dictionary',
'depts' => $this->dictDeptModel->findAll(),
];
return view('layout', [
'content' => view('dept/index', $data),
'page_title' => 'Department Dictionary',
'active_menu' => 'dept'
]);
}
public function save(): \CodeIgniter\HTTP\RedirectResponse
{
$data = ['name' => $this->request->getPost('name')];
$this->dictDeptModel->insert($data);
return redirect()->to('/dept');
}
public function update($id): \CodeIgniter\HTTP\RedirectResponse
{
$data = ['name' => $this->request->getPost('name')];
$this->dictDeptModel->update($id, $data);
return redirect()->to('/dept');
}
public function delete($id): \CodeIgniter\HTTP\RedirectResponse
{
$this->dictDeptModel->delete($id);
return redirect()->to('/dept');
}
}
```
**Dialog View Pattern (`dialog.php`):**
```php
<?php
$isEdit = isset($record);
$action = $isEdit ? '/controller/update/' . $record['id'] : '/controller/save';
$title = $isEdit ? 'Edit Title' : 'Add Title';
?>
<div x-data="{ open: false }">
<?php if (!$isEdit): ?>
<button @click="open = true" class="...">Add</button>
<?php endif; ?>
<div x-show="open" class="fixed inset-0 z-50 ..." style="display: none;">
<h2 class="text-xl font-bold mb-4"><?= $title ?></h2>
<form action="<?= $action ?>" method="post">
<!-- Form fields with values from $record if edit mode -->
<input type="text" name="name" value="<?= $record['name'] ?? '' ?>">
<button type="submit"><?= $isEdit ? 'Update' : 'Save' ?></button>
</form>
</div>
</div>
```
**Index View Pattern (`index.php`):**
```php
<div class="space-y-6">
<!-- Table with data attributes for edit/delete -->
<table>
<tbody>
<?php foreach ($records as $record): ?>
<tr>
<td><?= $record['name'] ?></td>
<td>
<button data-edit-id="<?= $record['id'] ?>"
data-name="<?= $record['name'] ?>"
class="...">Edit</button>
<button data-delete-id="<?= $record['id'] ?>"
class="...">Delete</button>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
<!-- Dialog for add (no data passed) -->
<?= view('module/dialog') ?>
<script>
// All modal-related JS in index.php
document.querySelectorAll('[data-edit-id]').forEach(btn => {
btn.addEventListener('click', function() {
document.getElementById('editId').value = this.dataset.editId;
document.getElementById('editName').value = this.dataset.name;
document.getElementById('editModal').classList.remove('hidden');
});
});
document.querySelectorAll('[data-delete-id]').forEach(btn => {
btn.addEventListener('click', function() {
if (confirm('Delete this record?')) {
window.location.href = '/controller/delete/' + this.dataset.deleteId;
}
});
});
</script>
```
**Searchable Multi-Select:**
- Use Select2 for searchable dropdowns (already included in layout.php)
- Initialize with: `$('#selectId').select2({ placeholder: 'Search...', allowClear: true })`
### Security Considerations
- Use CodeIgniter's built-in CSRF protection (`$this->validate('csrf')`)
- Escape all output in views with `<?= ?>` (auto-escaped)
- Use `$this->request->getPost()` instead of `$_POST`
- Never commit `.env` files with credentials
## Common Operations
**Add a new CRUD resource:**
1. Create model in `app/Models/`
2. Create controller in `app/Controllers/`
3. Add routes in `app/Config/Routes.php`
4. Create views in `app/Views/[module]/`
**Add a menu item:**
- Add to sidebar in `app/Views/layout.php`
- Add route in `app/Config/Routes.php`
- Create controller method
- Set `active_menu` parameter in view() call

22
LICENSE Normal file
View File

@ -0,0 +1,22 @@
The MIT License (MIT)
Copyright (c) 2014-2019 British Columbia Institute of Technology
Copyright (c) 2019-present CodeIgniter Foundation
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

68
README.md Normal file
View File

@ -0,0 +1,68 @@
# CodeIgniter 4 Application Starter
## What is CodeIgniter?
CodeIgniter is a PHP full-stack web framework that is light, fast, flexible and secure.
More information can be found at the [official site](https://codeigniter.com).
This repository holds a composer-installable app starter.
It has been built from the
[development repository](https://github.com/codeigniter4/CodeIgniter4).
More information about the plans for version 4 can be found in [CodeIgniter 4](https://forum.codeigniter.com/forumdisplay.php?fid=28) on the forums.
You can read the [user guide](https://codeigniter.com/user_guide/)
corresponding to the latest version of the framework.
## Installation & updates
`composer create-project codeigniter4/appstarter` then `composer update` whenever
there is a new release of the framework.
When updating, check the release notes to see if there are any changes you might need to apply
to your `app` folder. The affected files can be copied or merged from
`vendor/codeigniter4/framework/app`.
## Setup
Copy `env` to `.env` and tailor for your app, specifically the baseURL
and any database settings.
## Important Change with index.php
`index.php` is no longer in the root of the project! It has been moved inside the *public* folder,
for better security and separation of components.
This means that you should configure your web server to "point" to your project's *public* folder, and
not to the project root. A better practice would be to configure a virtual host to point there. A poor practice would be to point your web server to the project root and expect to enter *public/...*, as the rest of your logic and the
framework are exposed.
**Please** read the user guide for a better explanation of how CI4 works!
## Repository Management
We use GitHub issues, in our main repository, to track **BUGS** and to track approved **DEVELOPMENT** work packages.
We use our [forum](http://forum.codeigniter.com) to provide SUPPORT and to discuss
FEATURE REQUESTS.
This repository is a "distribution" one, built by our release preparation script.
Problems with it can be raised on our forum, or as issues in the main repository.
## Server Requirements
PHP version 8.1 or higher is required, with the following extensions installed:
- [intl](http://php.net/manual/en/intl.requirements.php)
- [mbstring](http://php.net/manual/en/mbstring.installation.php)
> [!WARNING]
> - The end of life date for PHP 7.4 was November 28, 2022.
> - The end of life date for PHP 8.0 was November 26, 2023.
> - If you are still using PHP 7.4 or 8.0, you should upgrade immediately.
> - The end of life date for PHP 8.1 will be December 31, 2025.
Additionally, make sure that the following extensions are enabled in your PHP:
- json (enabled by default - don't turn it off)
- [mysqlnd](http://php.net/manual/en/mysqlnd.install.php) if you plan to use MySQL
- [libcurl](http://php.net/manual/en/curl.requirements.php) if you plan to use the HTTP\CURLRequest library

531
VIEWS_RULES.md Normal file
View File

@ -0,0 +1,531 @@
# TinyLab View Rules
This document defines the view patterns and conventions used in TinyLab. Follow these rules when creating new views or modifying existing ones.
## 1. Directory Structure
```
app/Views/
├── layout/
│ ├── main_layout.php # Primary app layout (sidebar, navbar, dark mode)
│ └── form_layout.php # Lightweight layout for standalone forms
├── [module_name]/ # Feature module (e.g., patients, requests)
│ ├── index.php # Main list page
│ ├── dialog_form.php # Modal form (Create/Edit)
│ └── drawer_filter.php # Filter drawer (optional)
├── master/
│ └── [entity]/ # Master data entity (e.g., doctors, samples)
│ ├── index.php
│ └── dialog_form.php
└── errors/
└── html/
├── error_404.php
└── error_exception.php
```
## 2. Layout Extension
All pages must extend the appropriate layout:
```php
<?= $this->extend("layout/main_layout"); ?>
<?= $this->section("content") ?>
<!-- Page content here -->
<?= $this->endSection(); ?>
<?= $this->section("script") ?>
<!-- Alpine.js scripts here -->
<?= $this->endSection(); ?>
```
Use `form_layout.php` for standalone pages like login:
```php
<?= $this->extend("layout/form_layout"); ?>
```
## 3. Alpine.js Integration
### 3.1 Component Definition
Always use `alpine:init` event listener:
```php
<?= $this->section("script") ?>
<script type="module">
import Alpine from '<?= base_url('/assets/js/app.js'); ?>';
document.addEventListener('alpine:init', () => {
Alpine.data("componentName", () => ({
// State
loading: false,
showModal: false,
list: [],
item: null,
form: {},
errors: {},
keyword: '',
// Lifecycle
init() {
this.fetchList();
},
// Methods
async fetchList() {
this.loading = true;
try {
const res = await fetch(`${window.BASEURL}/api/resource`);
const data = await res.json();
this.list = data.data || [];
} catch (err) {
console.error(err);
} finally {
this.loading = false;
}
},
showForm(id = null) {
this.form = id ? this.list.find(x => x.id === id) : {};
this.showModal = true;
},
closeModal() {
this.showModal = false;
this.errors = {};
},
validate() {
this.errors = {};
if (!this.form.field) this.errors.field = 'Field is required';
return Object.keys(this.errors).length === 0;
},
async save() {
if (!this.validate()) return;
this.loading = true;
try {
const method = this.form.id ? 'PATCH' : 'POST';
const res = await fetch(`${window.BASEURL}/api/resource`, {
method,
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(this.form)
});
const data = await res.json();
if (data.status === 'success') {
this.closeModal();
this.fetchList();
}
} finally {
this.loading = false;
}
}
}));
});
Alpine.start();
</script>
<?= $this->endSection(); ?>
```
### 3.2 Alpine Data Attribute
Wrap page content in the component:
```php
<main x-data="componentName()">
<!-- Page content -->
</main>
```
## 4. Modal/Dialog Pattern
### 4.1 Standard Modal Structure
```php
<!-- Backdrop -->
<div x-show="showModal"
x-transition:enter="transition ease-out duration-200"
x-transition:enter-start="opacity-0"
x-transition:enter-end="opacity-100"
x-transition:leave="transition ease-in duration-150"
x-transition:leave-start="opacity-100"
x-transition:leave-end="opacity-0"
class="fixed inset-0 bg-slate-900/50 backdrop-blur-sm z-40"
@click="closeModal()">
</div>
<!-- Modal Panel -->
<div x-show="showModal"
x-cloak
x-transition:enter="transition ease-out duration-200"
x-transition:enter-start="opacity-0 translate-y-4 sm:translate-y-0 sm:scale-95"
x-transition:enter-end="opacity-100 translate-y-0 sm:scale-100"
x-transition:leave="transition ease-in duration-150"
x-transition:leave-start="opacity-100 translate-y-0 sm:scale-100"
x-transition:leave-end="opacity-0 translate-y-4 sm:translate-y-0 sm:scale-95"
class="fixed inset-0 z-50 flex items-center justify-center p-4">
<div class="bg-white rounded-2xl shadow-2xl w-full max-w-2xl" @click.stop>
<!-- Header -->
<div class="px-6 py-4 border-b border-slate-100 flex items-center justify-between">
<h3 class="text-lg font-semibold text-slate-800" x-text="form.id ? 'Edit' : 'New'"></h3>
<button @click="closeModal()" class="text-slate-400 hover:text-slate-600">
<i class="fa-solid fa-xmark text-xl"></i>
</button>
</div>
<!-- Form -->
<form @submit.prevent="save()">
<div class="p-6">
<!-- Form fields -->
<div class="grid grid-cols-2 gap-4">
<div>
<label class="block text-sm font-medium text-slate-700 mb-1">Field <span class="text-red-500">*</span></label>
<input type="text" x-model="form.field"
class="w-full px-4 py-2.5 text-sm bg-slate-50 border border-slate-200 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500/20 focus:border-blue-500 transition-all"
:class="{'border-red-300 bg-red-50': errors.field}" />
<p x-show="errors.field" x-text="errors.field" class="text-red-500 text-xs mt-1"></p>
</div>
</div>
</div>
<!-- Footer -->
<div class="flex items-center justify-end gap-3 px-6 py-4 border-t border-slate-100 bg-slate-50/50 rounded-b-2xl">
<button type="button" @click="closeModal()" class="px-4 py-2 text-sm font-medium text-slate-600 hover:text-slate-800 transition-colors">Cancel</button>
<button type="submit" :disabled="loading" class="px-4 py-2 text-sm font-medium text-white bg-blue-600 rounded-lg hover:bg-blue-700 disabled:opacity-50 disabled:cursor-not-allowed transition-colors">
<template x-if="!loading"><span><i class="fa-solid fa-check mr-1"></i> Save</span></template>
<template x-if="loading"><span><svg class="animate-spin h-4 w-4 mr-1 inline" viewBox="0 0 24 24"><!-- SVG --></svg> Saving...</span></template>
</button>
</div>
</form>
</div>
</div>
```
## 5. Page Structure Pattern
### 5.1 Standard CRUD Page
```php
<?= $this->extend("layout/main_layout"); ?>
<?= $this->section("content") ?>
<main x-data="componentName()">
<!-- Page Header -->
<div class="flex items-center justify-between mb-6">
<div>
<h1 class="text-2xl font-bold text-slate-800">Module Title</h1>
<p class="text-sm text-slate-500 mt-1">Module description</p>
</div>
<button @click="showForm()" class="btn btn-primary">
<i class="fa-solid fa-plus mr-2"></i>New Item
</button>
</div>
<!-- Search Card -->
<div class="bg-white rounded-xl border border-slate-100 shadow-sm p-4 mb-6">
<div class="flex gap-3">
<div class="flex-1 relative">
<i class="fa-solid fa-search absolute left-3 top-1/2 -translate-y-1/2 text-slate-400 text-sm"></i>
<input type="text" x-model="keyword" @keyup.enter="fetchList()"
class="w-full pl-10 pr-4 py-2.5 text-sm bg-slate-50 border border-slate-200 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500/20 focus:border-blue-500"
placeholder="Search..." />
</div>
<button @click="fetchList()" class="btn btn-primary">
<i class="fa-solid fa-search mr-2"></i>Search
</button>
</div>
</div>
<!-- Error Alert -->
<div x-show="error" x-transition class="bg-red-50 border border-red-200 text-red-700 px-4 py-3 rounded-lg mb-6">
<div class="flex items-center gap-2">
<i class="fa-solid fa-circle-exclamation"></i>
<span x-text="error"></span>
</div>
</div>
<!-- Data Table Card -->
<div class="bg-white rounded-xl border border-slate-100 shadow-sm overflow-hidden">
<!-- Loading State -->
<template x-if="loading">
<div class="p-12 text-center">
<div class="w-16 h-16 rounded-full bg-blue-50 flex items-center justify-center mx-auto mb-4">
<i class="fa-solid fa-spinner fa-spin text-blue-500 text-xl"></i>
</div>
<p class="text-slate-500 text-sm">Loading...</p>
</div>
</template>
<!-- Empty State -->
<template x-if="!loading && (!list || list.length === 0)">
<div class="flex-1 flex items-center justify-center p-8">
<div class="text-center">
<div class="w-12 h-12 rounded-full bg-slate-100 flex items-center justify-center mx-auto mb-3">
<i class="fa-solid fa-inbox text-slate-400"></i>
</div>
<p class="text-slate-500 text-sm">No data found</p>
</div>
</div>
</template>
<!-- Data Table -->
<template x-if="!loading && list && list.length > 0">
<table class="w-full text-sm text-left">
<thead class="bg-slate-50 text-slate-500 text-xs uppercase tracking-wider">
<tr>
<th class="py-3 px-5 font-semibold">#</th>
<th class="py-3 px-5 font-semibold">Code</th>
<th class="py-3 px-5 font-semibold">Name</th>
<th class="py-3 px-5 font-semibold text-right">Actions</th>
</tr>
</thead>
<tbody class="divide-y divide-slate-100">
<template x-for="(item, index) in list" :key="item.id">
<tr class="hover:bg-slate-50/50 transition-colors">
<td class="py-3 px-5" x-text="index + 1"></td>
<td class="py-3 px-5">
<span class="font-mono text-xs bg-slate-100 text-slate-600 px-2 py-1 rounded" x-text="item.code"></span>
</td>
<td class="py-3 px-5 font-medium text-slate-800" x-text="item.name"></td>
<td class="py-3 px-5 text-right">
<button @click="showForm(item.id)" class="text-blue-600 hover:text-blue-800 mr-3">
<i class="fa-solid fa-pen-to-square"></i>
</button>
<button @click="delete(item.id)" class="text-red-600 hover:text-red-800">
<i class="fa-solid fa-trash"></i>
</button>
</td>
</tr>
</template>
</tbody>
</table>
</template>
</div>
<!-- Dialog Include -->
<?= $this->include('module/dialog_form'); ?>
</main>
<?= $this->endSection(); ?>
```
### 5.2 Master-Detail Pattern
```php
<!-- Master-Detail Layout -->
<div class="flex-1 grid grid-cols-1 lg:grid-cols-3 gap-6 min-h-0">
<!-- List Panel -->
<div class="bg-white rounded-xl border border-slate-100 shadow-sm overflow-hidden flex flex-col">
<div class="p-4 border-b border-slate-100">
<input type="text" x-model="keyword" @keyup.enter="fetchList()" placeholder="Search..." class="w-full px-3 py-2 text-sm bg-slate-50 border border-slate-200 rounded-lg" />
</div>
<div class="flex-1 overflow-y-auto">
<template x-for="item in list" :key="item.id">
<div class="px-4 py-3 hover:bg-blue-50/50 cursor-pointer border-b border-slate-50"
:class="{'bg-blue-50': selectedId === item.id}"
@click="fetchDetail(item.id)">
<p class="font-medium text-slate-800" x-text="item.name"></p>
<p class="text-xs text-slate-500" x-text="item.code"></p>
</div>
</template>
</div>
</div>
<!-- Detail Panel -->
<div class="lg:col-span-2 bg-white rounded-xl border border-slate-100 shadow-sm">
<template x-if="!detail">
<div class="flex items-center justify-center h-full min-h-[400px] text-slate-400">
<div class="text-center">
<i class="fa-solid fa-folder-open text-4xl mb-3"></i>
<p>Select an item to view details</p>
</div>
</div>
</template>
<template x-if="detail">
<div class="p-6">
<!-- Detail content -->
</div>
</template>
</div>
</div>
```
## 6. Form Field Patterns
### 6.1 Input with Icon
```php
<div class="relative">
<i class="fa-solid fa-icon absolute left-3 top-1/2 -translate-y-1/2 text-slate-400 text-sm"></i>
<input type="text" x-model="form.field"
class="w-full pl-10 pr-4 py-2.5 text-sm bg-slate-50 border border-slate-200 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500/20 focus:border-blue-500 transition-all"
placeholder="Placeholder text" />
</div>
```
### 6.2 Select Dropdown
```php
<select x-model="form.field" class="w-full px-4 py-2.5 text-sm bg-slate-50 border border-slate-200 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500/20 focus:border-blue-500">
<option value="">-- Select --</option>
<template x-for="option in options" :key="option.value">
<option :value="option.value" x-text="option.label"></option>
</template>
</select>
```
### 6.3 Checkbox
```php
<label class="flex items-center gap-2 cursor-pointer">
<input type="checkbox" x-model="form.field" class="checkbox checkbox-sm checkbox-primary" />
<span class="text-sm text-slate-700">Checkbox label</span>
</label>
```
### 6.4 Radio Group
```php
<div class="flex gap-4">
<template x-for="option in options" :key="option.value">
<label class="flex items-center gap-2 cursor-pointer">
<input type="radio" :name="'fieldName'" :value="option.value" x-model="form.field" class="radio radio-sm radio-primary" />
<span class="text-sm text-slate-700" x-text="option.label"></span>
</label>
</template>
</div>
```
## 7. Status Badges
```php
<span class="px-2 py-0.5 rounded-full text-xs font-medium"
:class="{
'bg-amber-100 text-amber-700': status === 'P',
'bg-blue-100 text-blue-700': status === 'I',
'bg-emerald-100 text-emerald-700': status === 'C',
'bg-red-100 text-red-700': status === 'X'
}"
x-text="getStatusLabel(status)">
</span>
```
## 8. CSS Classes Reference
### Layout
- `flex`, `flex-col`, `grid`, `grid-cols-2`, `gap-4`
- `w-full`, `max-w-2xl`, `min-h-0`
- `overflow-hidden`, `overflow-y-auto`
### Spacing
- `p-4`, `px-6`, `py-3`, `m-4`, `mb-6`
- `space-x-4`, `gap-3`
### Typography
- `text-sm`, `text-xs`, `text-lg`, `text-2xl`
- `font-medium`, `font-semibold`, `font-bold`
- `text-slate-500`, `text-slate-800`
### Borders & Backgrounds
- `bg-white`, `bg-slate-50`, `bg-blue-50`
- `border`, `border-slate-100`, `border-red-300`
- `rounded-lg`, `rounded-xl`, `rounded-2xl`
### Components
- `btn btn-primary`, `btn btn-ghost`
- `checkbox checkbox-sm`
- `radio radio-primary`
- `input`, `select`, `textarea`
### Icons
FontAwesome 7 via CDN: `<i class="fa-solid fa-icon-name"></i>`
## 9. API Response Format
Views expect API responses in this format:
```json
{
"status": "success",
"message": "Operation successful",
"data": [...]
}
```
## 10. Validation Pattern
```javascript
validate() {
this.errors = {};
if (!this.form.field1) {
this.errors.field1 = 'Field 1 is required';
}
if (!this.form.field2) {
this.errors.field2 = 'Field 2 is required';
}
if (this.form.field3 && !/^\d+$/.test(this.form.field3)) {
this.errors.field3 = 'Must be numeric';
}
return Object.keys(this.errors).length === 0;
}
```
## 11. Error Handling
```javascript
async save() {
this.loading = true;
try {
const res = await fetch(url, { ... });
const data = await res.json();
if (data.status === 'success') {
this.showToast('Saved successfully');
this.fetchList();
} else {
this.error = data.message || 'An error occurred';
}
} catch (err) {
this.error = 'Network error. Please try again.';
console.error(err);
} finally {
this.loading = false;
}
}
```
## 12. Quick Reference: File Templates
### Standard List Page Template
See: `app/Views/master/doctors/doctors_index.php`
### Modal Form Template
See: `app/Views/master/doctors/dialog_doctors_form.php`
### Master-Detail Page Template
See: `app/Views/patients/patients_index.php`
### Result Entry Table Template
See: `app/Views/requests/dialog_result_entry.php`
## 13. Checklist for New Views
- [ ] Create view file in correct directory
- [ ] Extend appropriate layout (`main_layout` or `form_layout`)
- [ ] Define `content` and `script` sections
- [ ] Wrap content in `x-data` component
- [ ] Include modal form if needed
- [ ] Use DaisyUI components for buttons, inputs, selects
- [ ] Add loading and empty states
- [ ] Implement proper error handling
- [ ] Use FontAwesome icons consistently
- [ ] Follow naming conventions (snake_case for PHP, camelCase for JS)
## 14. Conventions Summary
| Aspect | Convention |
|--------|------------|
| File naming | snake_case (e.g., `patients_index.php`) |
| PHP variables | snake_case |
| JavaScript variables | camelCase |
| HTML classes | kebab-case (Tailwind) |
| Icons | FontAwesome 7 |
| UI Framework | TailwindCSS + DaisyUI |
| State management | Alpine.js |
| API format | JSON with `status`, `message`, `data` |
| Primary key | `{table}_id` (e.g., `pat_id`) |
| Soft deletes | All tables use `deleted_at` |

6
app/.htaccess Normal file
View File

@ -0,0 +1,6 @@
<IfModule authz_core_module>
Require all denied
</IfModule>
<IfModule !authz_core_module>
Deny from all
</IfModule>

15
app/Common.php Normal file
View File

@ -0,0 +1,15 @@
<?php
/**
* The goal of this file is to allow developers a location
* where they can overwrite core procedural functions and
* replace them with their own. This file is loaded during
* the bootstrap process and is called during the framework's
* execution.
*
* This can be looked at as a `master helper` file that is
* loaded early on, and may also contain additional functions
* that you'd like to use throughout your entire application
*
* @see: https://codeigniter.com/user_guide/extending/common.html
*/

202
app/Config/App.php Normal file
View File

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

92
app/Config/Autoload.php Normal file
View File

@ -0,0 +1,92 @@
<?php
namespace Config;
use CodeIgniter\Config\AutoloadConfig;
/**
* -------------------------------------------------------------------
* AUTOLOADER CONFIGURATION
* -------------------------------------------------------------------
*
* This file defines the namespaces and class maps so the Autoloader
* can find the files as needed.
*
* NOTE: If you use an identical key in $psr4 or $classmap, then
* the values in this file will overwrite the framework's values.
*
* NOTE: This class is required prior to Autoloader instantiation,
* and does not extend BaseConfig.
*/
class Autoload extends AutoloadConfig
{
/**
* -------------------------------------------------------------------
* Namespaces
* -------------------------------------------------------------------
* This maps the locations of any namespaces in your application to
* their location on the file system. These are used by the autoloader
* to locate files the first time they have been instantiated.
*
* The 'Config' (APPPATH . 'Config') and 'CodeIgniter' (SYSTEMPATH) are
* already mapped for you.
*
* You may change the name of the 'App' namespace if you wish,
* but this should be done prior to creating any namespaced classes,
* else you will need to modify all of those classes for this to work.
*
* @var array<string, list<string>|string>
*/
public $psr4 = [
APP_NAMESPACE => APPPATH,
];
/**
* -------------------------------------------------------------------
* Class Map
* -------------------------------------------------------------------
* The class map provides a map of class names and their exact
* location on the drive. Classes loaded in this manner will have
* slightly faster performance because they will not have to be
* searched for within one or more directories as they would if they
* were being autoloaded through a namespace.
*
* Prototype:
* $classmap = [
* 'MyClass' => '/path/to/class/file.php'
* ];
*
* @var array<string, string>
*/
public $classmap = [];
/**
* -------------------------------------------------------------------
* Files
* -------------------------------------------------------------------
* The files array provides a list of paths to __non-class__ files
* that will be autoloaded. This can be useful for bootstrap operations
* or for loading functions.
*
* Prototype:
* $files = [
* '/path/to/my/file.php',
* ];
*
* @var list<string>
*/
public $files = [];
/**
* -------------------------------------------------------------------
* Helpers
* -------------------------------------------------------------------
* Prototype:
* $helpers = [
* 'form',
* ];
*
* @var list<string>
*/
public $helpers = [];
}

View File

@ -0,0 +1,34 @@
<?php
/*
|--------------------------------------------------------------------------
| ERROR DISPLAY
|--------------------------------------------------------------------------
| In development, we want to show as many errors as possible to help
| make sure they don't make it to production. And save us hours of
| painful debugging.
|
| If you set 'display_errors' to '1', CI4's detailed error report will show.
*/
error_reporting(E_ALL);
ini_set('display_errors', '1');
/*
|--------------------------------------------------------------------------
| DEBUG BACKTRACES
|--------------------------------------------------------------------------
| If true, this constant will tell the error screens to display debug
| backtraces along with the other error information. If you would
| prefer to not see this, set this value to false.
*/
defined('SHOW_DEBUG_BACKTRACE') || define('SHOW_DEBUG_BACKTRACE', true);
/*
|--------------------------------------------------------------------------
| DEBUG MODE
|--------------------------------------------------------------------------
| Debug mode is an experimental flag that can allow changes throughout
| the system. This will control whether Kint is loaded, and a few other
| items. It can always be used within your own application too.
*/
defined('CI_DEBUG') || define('CI_DEBUG', true);

View File

@ -0,0 +1,25 @@
<?php
/*
|--------------------------------------------------------------------------
| ERROR DISPLAY
|--------------------------------------------------------------------------
| Don't show ANY in production environments. Instead, let the system catch
| it and display a generic error message.
|
| If you set 'display_errors' to '1', CI4's detailed error report will show.
*/
error_reporting(E_ALL & ~E_DEPRECATED);
// If you want to suppress more types of errors.
// error_reporting(E_ALL & ~E_NOTICE & ~E_DEPRECATED & ~E_STRICT & ~E_USER_NOTICE & ~E_USER_DEPRECATED);
ini_set('display_errors', '0');
/*
|--------------------------------------------------------------------------
| DEBUG MODE
|--------------------------------------------------------------------------
| Debug mode is an experimental flag that can allow changes throughout
| the system. It's not widely used currently, and may not survive
| release of the framework.
*/
defined('CI_DEBUG') || define('CI_DEBUG', false);

View File

@ -0,0 +1,38 @@
<?php
/*
* The environment testing is reserved for PHPUnit testing. It has special
* conditions built into the framework at various places to assist with that.
* You cant use it for your development.
*/
/*
|--------------------------------------------------------------------------
| ERROR DISPLAY
|--------------------------------------------------------------------------
| In development, we want to show as many errors as possible to help
| make sure they don't make it to production. And save us hours of
| painful debugging.
*/
error_reporting(E_ALL);
ini_set('display_errors', '1');
/*
|--------------------------------------------------------------------------
| DEBUG BACKTRACES
|--------------------------------------------------------------------------
| If true, this constant will tell the error screens to display debug
| backtraces along with the other error information. If you would
| prefer to not see this, set this value to false.
*/
defined('SHOW_DEBUG_BACKTRACE') || define('SHOW_DEBUG_BACKTRACE', true);
/*
|--------------------------------------------------------------------------
| DEBUG MODE
|--------------------------------------------------------------------------
| Debug mode is an experimental flag that can allow changes throughout
| the system. It's not widely used currently, and may not survive
| release of the framework.
*/
defined('CI_DEBUG') || define('CI_DEBUG', true);

View File

@ -0,0 +1,20 @@
<?php
namespace Config;
use CodeIgniter\Config\BaseConfig;
class CURLRequest extends BaseConfig
{
/**
* --------------------------------------------------------------------------
* CURLRequest Share Options
* --------------------------------------------------------------------------
*
* Whether share options between requests or not.
*
* If true, all the options won't be reset between requests.
* It may cause an error request with unnecessary headers.
*/
public bool $shareOptions = false;
}

162
app/Config/Cache.php Normal file
View File

@ -0,0 +1,162 @@
<?php
namespace Config;
use CodeIgniter\Cache\CacheInterface;
use CodeIgniter\Cache\Handlers\DummyHandler;
use CodeIgniter\Cache\Handlers\FileHandler;
use CodeIgniter\Cache\Handlers\MemcachedHandler;
use CodeIgniter\Cache\Handlers\PredisHandler;
use CodeIgniter\Cache\Handlers\RedisHandler;
use CodeIgniter\Cache\Handlers\WincacheHandler;
use CodeIgniter\Config\BaseConfig;
class Cache extends BaseConfig
{
/**
* --------------------------------------------------------------------------
* Primary Handler
* --------------------------------------------------------------------------
*
* The name of the preferred handler that should be used. If for some reason
* it is not available, the $backupHandler will be used in its place.
*/
public string $handler = 'file';
/**
* --------------------------------------------------------------------------
* Backup Handler
* --------------------------------------------------------------------------
*
* The name of the handler that will be used in case the first one is
* unreachable. Often, 'file' is used here since the filesystem is
* always available, though that's not always practical for the app.
*/
public string $backupHandler = 'dummy';
/**
* --------------------------------------------------------------------------
* Key Prefix
* --------------------------------------------------------------------------
*
* This string is added to all cache item names to help avoid collisions
* if you run multiple applications with the same cache engine.
*/
public string $prefix = '';
/**
* --------------------------------------------------------------------------
* Default TTL
* --------------------------------------------------------------------------
*
* The default number of seconds to save items when none is specified.
*
* WARNING: This is not used by framework handlers where 60 seconds is
* hard-coded, but may be useful to projects and modules. This will replace
* the hard-coded value in a future release.
*/
public int $ttl = 60;
/**
* --------------------------------------------------------------------------
* Reserved Characters
* --------------------------------------------------------------------------
*
* A string of reserved characters that will not be allowed in keys or tags.
* Strings that violate this restriction will cause handlers to throw.
* Default: {}()/\@:
*
* NOTE: The default set is required for PSR-6 compliance.
*/
public string $reservedCharacters = '{}()/\@:';
/**
* --------------------------------------------------------------------------
* File settings
* --------------------------------------------------------------------------
*
* Your file storage preferences can be specified below, if you are using
* the File driver.
*
* @var array{storePath?: string, mode?: int}
*/
public array $file = [
'storePath' => WRITEPATH . 'cache/',
'mode' => 0640,
];
/**
* -------------------------------------------------------------------------
* Memcached settings
* -------------------------------------------------------------------------
*
* Your Memcached servers can be specified below, if you are using
* the Memcached drivers.
*
* @see https://codeigniter.com/user_guide/libraries/caching.html#memcached
*
* @var array{host?: string, port?: int, weight?: int, raw?: bool}
*/
public array $memcached = [
'host' => '127.0.0.1',
'port' => 11211,
'weight' => 1,
'raw' => false,
];
/**
* -------------------------------------------------------------------------
* Redis settings
* -------------------------------------------------------------------------
*
* Your Redis server can be specified below, if you are using
* the Redis or Predis drivers.
*
* @var array{host?: string, password?: string|null, port?: int, timeout?: int, database?: int}
*/
public array $redis = [
'host' => '127.0.0.1',
'password' => null,
'port' => 6379,
'timeout' => 0,
'database' => 0,
];
/**
* --------------------------------------------------------------------------
* Available Cache Handlers
* --------------------------------------------------------------------------
*
* This is an array of cache engine alias' and class names. Only engines
* that are listed here are allowed to be used.
*
* @var array<string, class-string<CacheInterface>>
*/
public array $validHandlers = [
'dummy' => DummyHandler::class,
'file' => FileHandler::class,
'memcached' => MemcachedHandler::class,
'predis' => PredisHandler::class,
'redis' => RedisHandler::class,
'wincache' => WincacheHandler::class,
];
/**
* --------------------------------------------------------------------------
* Web Page Caching: Cache Include Query String
* --------------------------------------------------------------------------
*
* Whether to take the URL query string into consideration when generating
* output cache files. Valid options are:
*
* false = Disabled
* true = Enabled, take all query parameters into account.
* Please be aware that this may result in numerous cache
* files generated for the same page over and over again.
* ['q'] = Enabled, but only take into account the specified list
* of query parameters.
*
* @var bool|list<string>
*/
public $cacheQueryString = false;
}

79
app/Config/Constants.php Normal file
View File

@ -0,0 +1,79 @@
<?php
/*
| --------------------------------------------------------------------
| App Namespace
| --------------------------------------------------------------------
|
| This defines the default Namespace that is used throughout
| CodeIgniter to refer to the Application directory. Change
| this constant to change the namespace that all application
| classes should use.
|
| NOTE: changing this will require manually modifying the
| existing namespaces of App\* namespaced-classes.
*/
defined('APP_NAMESPACE') || define('APP_NAMESPACE', 'App');
/*
| --------------------------------------------------------------------------
| Composer Path
| --------------------------------------------------------------------------
|
| The path that Composer's autoload file is expected to live. By default,
| the vendor folder is in the Root directory, but you can customize that here.
*/
defined('COMPOSER_PATH') || define('COMPOSER_PATH', ROOTPATH . 'vendor/autoload.php');
/*
|--------------------------------------------------------------------------
| Timing Constants
|--------------------------------------------------------------------------
|
| Provide simple ways to work with the myriad of PHP functions that
| require information to be in seconds.
*/
defined('SECOND') || define('SECOND', 1);
defined('MINUTE') || define('MINUTE', 60);
defined('HOUR') || define('HOUR', 3600);
defined('DAY') || define('DAY', 86400);
defined('WEEK') || define('WEEK', 604800);
defined('MONTH') || define('MONTH', 2_592_000);
defined('YEAR') || define('YEAR', 31_536_000);
defined('DECADE') || define('DECADE', 315_360_000);
/*
| --------------------------------------------------------------------------
| Exit Status Codes
| --------------------------------------------------------------------------
|
| Used to indicate the conditions under which the script is exit()ing.
| While there is no universal standard for error codes, there are some
| broad conventions. Three such conventions are mentioned below, for
| those who wish to make use of them. The CodeIgniter defaults were
| chosen for the least overlap with these conventions, while still
| leaving room for others to be defined in future versions and user
| applications.
|
| The three main conventions used for determining exit status codes
| are as follows:
|
| Standard C/C++ Library (stdlibc):
| http://www.gnu.org/software/libc/manual/html_node/Exit-Status.html
| (This link also contains other GNU-specific conventions)
| BSD sysexits.h:
| http://www.gsp.com/cgi-bin/man.cgi?section=3&topic=sysexits
| Bash scripting:
| http://tldp.org/LDP/abs/html/exitcodes.html
|
*/
defined('EXIT_SUCCESS') || define('EXIT_SUCCESS', 0); // no errors
defined('EXIT_ERROR') || define('EXIT_ERROR', 1); // generic error
defined('EXIT_CONFIG') || define('EXIT_CONFIG', 3); // configuration error
defined('EXIT_UNKNOWN_FILE') || define('EXIT_UNKNOWN_FILE', 4); // file not found
defined('EXIT_UNKNOWN_CLASS') || define('EXIT_UNKNOWN_CLASS', 5); // unknown class
defined('EXIT_UNKNOWN_METHOD') || define('EXIT_UNKNOWN_METHOD', 6); // unknown class member
defined('EXIT_USER_INPUT') || define('EXIT_USER_INPUT', 7); // invalid user input
defined('EXIT_DATABASE') || define('EXIT_DATABASE', 8); // database error
defined('EXIT__AUTO_MIN') || define('EXIT__AUTO_MIN', 9); // lowest automatically-assigned error code
defined('EXIT__AUTO_MAX') || define('EXIT__AUTO_MAX', 125); // highest automatically-assigned error code

View File

@ -0,0 +1,176 @@
<?php
namespace Config;
use CodeIgniter\Config\BaseConfig;
/**
* Stores the default settings for the ContentSecurityPolicy, if you
* choose to use it. The values here will be read in and set as defaults
* for the site. If needed, they can be overridden on a page-by-page basis.
*
* Suggested reference for explanations:
*
* @see https://www.html5rocks.com/en/tutorials/security/content-security-policy/
*/
class ContentSecurityPolicy extends BaseConfig
{
// -------------------------------------------------------------------------
// Broadbrush CSP management
// -------------------------------------------------------------------------
/**
* Default CSP report context
*/
public bool $reportOnly = false;
/**
* Specifies a URL where a browser will send reports
* when a content security policy is violated.
*/
public ?string $reportURI = null;
/**
* Instructs user agents to rewrite URL schemes, changing
* HTTP to HTTPS. This directive is for websites with
* large numbers of old URLs that need to be rewritten.
*/
public bool $upgradeInsecureRequests = false;
// -------------------------------------------------------------------------
// Sources allowed
// NOTE: once you set a policy to 'none', it cannot be further restricted
// -------------------------------------------------------------------------
/**
* Will default to self if not overridden
*
* @var list<string>|string|null
*/
public $defaultSrc;
/**
* Lists allowed scripts' URLs.
*
* @var list<string>|string
*/
public $scriptSrc = 'self';
/**
* Lists allowed stylesheets' URLs.
*
* @var list<string>|string
*/
public $styleSrc = 'self';
/**
* Defines the origins from which images can be loaded.
*
* @var list<string>|string
*/
public $imageSrc = 'self';
/**
* Restricts the URLs that can appear in a page's `<base>` element.
*
* Will default to self if not overridden
*
* @var list<string>|string|null
*/
public $baseURI;
/**
* Lists the URLs for workers and embedded frame contents
*
* @var list<string>|string
*/
public $childSrc = 'self';
/**
* Limits the origins that you can connect to (via XHR,
* WebSockets, and EventSource).
*
* @var list<string>|string
*/
public $connectSrc = 'self';
/**
* Specifies the origins that can serve web fonts.
*
* @var list<string>|string
*/
public $fontSrc;
/**
* Lists valid endpoints for submission from `<form>` tags.
*
* @var list<string>|string
*/
public $formAction = 'self';
/**
* Specifies the sources that can embed the current page.
* This directive applies to `<frame>`, `<iframe>`, `<embed>`,
* and `<applet>` tags. This directive can't be used in
* `<meta>` tags and applies only to non-HTML resources.
*
* @var list<string>|string|null
*/
public $frameAncestors;
/**
* The frame-src directive restricts the URLs which may
* be loaded into nested browsing contexts.
*
* @var list<string>|string|null
*/
public $frameSrc;
/**
* Restricts the origins allowed to deliver video and audio.
*
* @var list<string>|string|null
*/
public $mediaSrc;
/**
* Allows control over Flash and other plugins.
*
* @var list<string>|string
*/
public $objectSrc = 'self';
/**
* @var list<string>|string|null
*/
public $manifestSrc;
/**
* Limits the kinds of plugins a page may invoke.
*
* @var list<string>|string|null
*/
public $pluginTypes;
/**
* List of actions allowed.
*
* @var list<string>|string|null
*/
public $sandbox;
/**
* Nonce tag for style
*/
public string $styleNonceTag = '{csp-style-nonce}';
/**
* Nonce tag for script
*/
public string $scriptNonceTag = '{csp-script-nonce}';
/**
* Replace nonce tag automatically
*/
public bool $autoNonce = true;
}

107
app/Config/Cookie.php Normal file
View File

@ -0,0 +1,107 @@
<?php
namespace Config;
use CodeIgniter\Config\BaseConfig;
use DateTimeInterface;
class Cookie extends BaseConfig
{
/**
* --------------------------------------------------------------------------
* Cookie Prefix
* --------------------------------------------------------------------------
*
* Set a cookie name prefix if you need to avoid collisions.
*/
public string $prefix = '';
/**
* --------------------------------------------------------------------------
* Cookie Expires Timestamp
* --------------------------------------------------------------------------
*
* Default expires timestamp for cookies. Setting this to `0` will mean the
* cookie will not have the `Expires` attribute and will behave as a session
* cookie.
*
* @var DateTimeInterface|int|string
*/
public $expires = 0;
/**
* --------------------------------------------------------------------------
* Cookie Path
* --------------------------------------------------------------------------
*
* Typically will be a forward slash.
*/
public string $path = '/';
/**
* --------------------------------------------------------------------------
* Cookie Domain
* --------------------------------------------------------------------------
*
* Set to `.your-domain.com` for site-wide cookies.
*/
public string $domain = '';
/**
* --------------------------------------------------------------------------
* Cookie Secure
* --------------------------------------------------------------------------
*
* Cookie will only be set if a secure HTTPS connection exists.
*/
public bool $secure = false;
/**
* --------------------------------------------------------------------------
* Cookie HTTPOnly
* --------------------------------------------------------------------------
*
* Cookie will only be accessible via HTTP(S) (no JavaScript).
*/
public bool $httponly = true;
/**
* --------------------------------------------------------------------------
* Cookie SameSite
* --------------------------------------------------------------------------
*
* Configure cookie SameSite setting. Allowed values are:
* - None
* - Lax
* - Strict
* - ''
*
* Alternatively, you can use the constant names:
* - `Cookie::SAMESITE_NONE`
* - `Cookie::SAMESITE_LAX`
* - `Cookie::SAMESITE_STRICT`
*
* Defaults to `Lax` for compatibility with modern browsers. Setting `''`
* (empty string) means default SameSite attribute set by browsers (`Lax`)
* will be set on cookies. If set to `None`, `$secure` must also be set.
*
* @var ''|'Lax'|'None'|'Strict'
*/
public string $samesite = 'Lax';
/**
* --------------------------------------------------------------------------
* Cookie Raw
* --------------------------------------------------------------------------
*
* This flag allows setting a "raw" cookie, i.e., its name and value are
* not URL encoded using `rawurlencode()`.
*
* If this is set to `true`, cookie names should be compliant of RFC 2616's
* list of allowed characters.
*
* @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie#attributes
* @see https://tools.ietf.org/html/rfc2616#section-2.2
*/
public bool $raw = false;
}

105
app/Config/Cors.php Normal file
View File

@ -0,0 +1,105 @@
<?php
namespace Config;
use CodeIgniter\Config\BaseConfig;
/**
* Cross-Origin Resource Sharing (CORS) Configuration
*
* @see https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS
*/
class Cors extends BaseConfig
{
/**
* The default CORS configuration.
*
* @var array{
* allowedOrigins: list<string>,
* allowedOriginsPatterns: list<string>,
* supportsCredentials: bool,
* allowedHeaders: list<string>,
* exposedHeaders: list<string>,
* allowedMethods: list<string>,
* maxAge: int,
* }
*/
public array $default = [
/**
* Origins for the `Access-Control-Allow-Origin` header.
*
* @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Allow-Origin
*
* E.g.:
* - ['http://localhost:8080']
* - ['https://www.example.com']
*/
'allowedOrigins' => [],
/**
* Origin regex patterns for the `Access-Control-Allow-Origin` header.
*
* @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Allow-Origin
*
* NOTE: A pattern specified here is part of a regular expression. It will
* be actually `#\A<pattern>\z#`.
*
* E.g.:
* - ['https://\w+\.example\.com']
*/
'allowedOriginsPatterns' => [],
/**
* Weather to send the `Access-Control-Allow-Credentials` header.
*
* The Access-Control-Allow-Credentials response header tells browsers whether
* the server allows cross-origin HTTP requests to include credentials.
*
* @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Allow-Credentials
*/
'supportsCredentials' => false,
/**
* Set headers to allow.
*
* The Access-Control-Allow-Headers response header is used in response to
* a preflight request which includes the Access-Control-Request-Headers to
* indicate which HTTP headers can be used during the actual request.
*
* @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Allow-Headers
*/
'allowedHeaders' => [],
/**
* Set headers to expose.
*
* The Access-Control-Expose-Headers response header allows a server to
* indicate which response headers should be made available to scripts running
* in the browser, in response to a cross-origin request.
*
* @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Expose-Headers
*/
'exposedHeaders' => [],
/**
* Set methods to allow.
*
* The Access-Control-Allow-Methods response header specifies one or more
* methods allowed when accessing a resource in response to a preflight
* request.
*
* E.g.:
* - ['GET', 'POST', 'PUT', 'DELETE']
*
* @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Allow-Methods
*/
'allowedMethods' => [],
/**
* Set how many seconds the results of a preflight request can be cached.
*
* @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Max-Age
*/
'maxAge' => 7200,
];
}

204
app/Config/Database.php Normal file
View File

@ -0,0 +1,204 @@
<?php
namespace Config;
use CodeIgniter\Database\Config;
/**
* Database Configuration
*/
class Database extends Config
{
/**
* The directory that holds the Migrations and Seeds directories.
*/
public string $filesPath = APPPATH . 'Database' . DIRECTORY_SEPARATOR;
/**
* Lets you choose which connection group to use if no other is specified.
*/
public string $defaultGroup = 'default';
/**
* The default database connection.
*
* @var array<string, mixed>
*/
public array $default = [
'DSN' => '',
'hostname' => 'localhost',
'username' => '',
'password' => '',
'database' => '',
'DBDriver' => 'MySQLi',
'DBPrefix' => '',
'pConnect' => false,
'DBDebug' => true,
'charset' => 'utf8mb4',
'DBCollat' => 'utf8mb4_general_ci',
'swapPre' => '',
'encrypt' => false,
'compress' => false,
'strictOn' => false,
'failover' => [],
'port' => 3306,
'numberNative' => false,
'foundRows' => false,
'dateFormat' => [
'date' => 'Y-m-d',
'datetime' => 'Y-m-d H:i:s',
'time' => 'H:i:s',
],
];
// /**
// * Sample database connection for SQLite3.
// *
// * @var array<string, mixed>
// */
// public array $default = [
// 'database' => 'database.db',
// 'DBDriver' => 'SQLite3',
// 'DBPrefix' => '',
// 'DBDebug' => true,
// 'swapPre' => '',
// 'failover' => [],
// 'foreignKeys' => true,
// 'busyTimeout' => 1000,
// 'synchronous' => null,
// 'dateFormat' => [
// 'date' => 'Y-m-d',
// 'datetime' => 'Y-m-d H:i:s',
// 'time' => 'H:i:s',
// ],
// ];
// /**
// * Sample database connection for Postgre.
// *
// * @var array<string, mixed>
// */
// public array $default = [
// 'DSN' => '',
// 'hostname' => 'localhost',
// 'username' => 'root',
// 'password' => 'root',
// 'database' => 'ci4',
// 'schema' => 'public',
// 'DBDriver' => 'Postgre',
// 'DBPrefix' => '',
// 'pConnect' => false,
// 'DBDebug' => true,
// 'charset' => 'utf8',
// 'swapPre' => '',
// 'failover' => [],
// 'port' => 5432,
// 'dateFormat' => [
// 'date' => 'Y-m-d',
// 'datetime' => 'Y-m-d H:i:s',
// 'time' => 'H:i:s',
// ],
// ];
// /**
// * Sample database connection for SQLSRV.
// *
// * @var array<string, mixed>
// */
// public array $default = [
// 'DSN' => '',
// 'hostname' => 'localhost',
// 'username' => 'root',
// 'password' => 'root',
// 'database' => 'ci4',
// 'schema' => 'dbo',
// 'DBDriver' => 'SQLSRV',
// 'DBPrefix' => '',
// 'pConnect' => false,
// 'DBDebug' => true,
// 'charset' => 'utf8',
// 'swapPre' => '',
// 'encrypt' => false,
// 'failover' => [],
// 'port' => 1433,
// 'dateFormat' => [
// 'date' => 'Y-m-d',
// 'datetime' => 'Y-m-d H:i:s',
// 'time' => 'H:i:s',
// ],
// ];
// /**
// * Sample database connection for OCI8.
// *
// * You may need the following environment variables:
// * NLS_LANG = 'AMERICAN_AMERICA.UTF8'
// * NLS_DATE_FORMAT = 'YYYY-MM-DD HH24:MI:SS'
// * NLS_TIMESTAMP_FORMAT = 'YYYY-MM-DD HH24:MI:SS'
// * NLS_TIMESTAMP_TZ_FORMAT = 'YYYY-MM-DD HH24:MI:SS'
// *
// * @var array<string, mixed>
// */
// public array $default = [
// 'DSN' => 'localhost:1521/XEPDB1',
// 'username' => 'root',
// 'password' => 'root',
// 'DBDriver' => 'OCI8',
// 'DBPrefix' => '',
// 'pConnect' => false,
// 'DBDebug' => true,
// 'charset' => 'AL32UTF8',
// 'swapPre' => '',
// 'failover' => [],
// 'dateFormat' => [
// 'date' => 'Y-m-d',
// 'datetime' => 'Y-m-d H:i:s',
// 'time' => 'H:i:s',
// ],
// ];
/**
* This database connection is used when running PHPUnit database tests.
*
* @var array<string, mixed>
*/
public array $tests = [
'DSN' => '',
'hostname' => '127.0.0.1',
'username' => '',
'password' => '',
'database' => ':memory:',
'DBDriver' => 'SQLite3',
'DBPrefix' => 'db_', // Needed to ensure we're working correctly with prefixes live. DO NOT REMOVE FOR CI DEVS
'pConnect' => false,
'DBDebug' => true,
'charset' => 'utf8',
'DBCollat' => '',
'swapPre' => '',
'encrypt' => false,
'compress' => false,
'strictOn' => false,
'failover' => [],
'port' => 3306,
'foreignKeys' => true,
'busyTimeout' => 1000,
'synchronous' => null,
'dateFormat' => [
'date' => 'Y-m-d',
'datetime' => 'Y-m-d H:i:s',
'time' => 'H:i:s',
],
];
public function __construct()
{
parent::__construct();
// Ensure that we always set the database group to 'tests' if
// we are currently running an automated test suite, so that
// we don't overwrite live data on accident.
if (ENVIRONMENT === 'testing') {
$this->defaultGroup = 'tests';
}
}
}

43
app/Config/DocTypes.php Normal file
View File

@ -0,0 +1,43 @@
<?php
namespace Config;
class DocTypes
{
/**
* List of valid document types.
*
* @var array<string, string>
*/
public array $list = [
'xhtml11' => '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">',
'xhtml1-strict' => '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">',
'xhtml1-trans' => '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">',
'xhtml1-frame' => '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">',
'xhtml-basic11' => '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML Basic 1.1//EN" "http://www.w3.org/TR/xhtml-basic/xhtml-basic11.dtd">',
'html5' => '<!DOCTYPE html>',
'html4-strict' => '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">',
'html4-trans' => '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">',
'html4-frame' => '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">',
'mathml1' => '<!DOCTYPE math SYSTEM "http://www.w3.org/Math/DTD/mathml1/mathml.dtd">',
'mathml2' => '<!DOCTYPE math PUBLIC "-//W3C//DTD MathML 2.0//EN" "http://www.w3.org/Math/DTD/mathml2/mathml2.dtd">',
'svg10' => '<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.0//EN" "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">',
'svg11' => '<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">',
'svg11-basic' => '<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1 Basic//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11-basic.dtd">',
'svg11-tiny' => '<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1 Tiny//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11-tiny.dtd">',
'xhtml-math-svg-xh' => '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1 plus MathML 2.0 plus SVG 1.1//EN" "http://www.w3.org/2002/04/xhtml-math-svg/xhtml-math-svg.dtd">',
'xhtml-math-svg-sh' => '<!DOCTYPE svg:svg PUBLIC "-//W3C//DTD XHTML 1.1 plus MathML 2.0 plus SVG 1.1//EN" "http://www.w3.org/2002/04/xhtml-math-svg/xhtml-math-svg.dtd">',
'xhtml-rdfa-1' => '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML+RDFa 1.0//EN" "http://www.w3.org/MarkUp/DTD/xhtml-rdfa-1.dtd">',
'xhtml-rdfa-2' => '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML+RDFa 1.1//EN" "http://www.w3.org/MarkUp/DTD/xhtml-rdfa-2.dtd">',
];
/**
* Whether to remove the solidus (`/`) character for void HTML elements (e.g. `<input>`)
* for HTML5 compatibility.
*
* Set to:
* `true` - to be HTML5 compatible
* `false` - to be XHTML compatible
*/
public bool $html5 = true;
}

121
app/Config/Email.php Normal file
View File

@ -0,0 +1,121 @@
<?php
namespace Config;
use CodeIgniter\Config\BaseConfig;
class Email extends BaseConfig
{
public string $fromEmail = '';
public string $fromName = '';
public string $recipients = '';
/**
* The "user agent"
*/
public string $userAgent = 'CodeIgniter';
/**
* The mail sending protocol: mail, sendmail, smtp
*/
public string $protocol = 'mail';
/**
* The server path to Sendmail.
*/
public string $mailPath = '/usr/sbin/sendmail';
/**
* SMTP Server Hostname
*/
public string $SMTPHost = '';
/**
* SMTP Username
*/
public string $SMTPUser = '';
/**
* SMTP Password
*/
public string $SMTPPass = '';
/**
* SMTP Port
*/
public int $SMTPPort = 25;
/**
* SMTP Timeout (in seconds)
*/
public int $SMTPTimeout = 5;
/**
* Enable persistent SMTP connections
*/
public bool $SMTPKeepAlive = false;
/**
* SMTP Encryption.
*
* @var string '', 'tls' or 'ssl'. 'tls' will issue a STARTTLS command
* to the server. 'ssl' means implicit SSL. Connection on port
* 465 should set this to ''.
*/
public string $SMTPCrypto = 'tls';
/**
* Enable word-wrap
*/
public bool $wordWrap = true;
/**
* Character count to wrap at
*/
public int $wrapChars = 76;
/**
* Type of mail, either 'text' or 'html'
*/
public string $mailType = 'text';
/**
* Character set (utf-8, iso-8859-1, etc.)
*/
public string $charset = 'UTF-8';
/**
* Whether to validate the email address
*/
public bool $validate = false;
/**
* Email Priority. 1 = highest. 5 = lowest. 3 = normal
*/
public int $priority = 3;
/**
* Newline character. (Use “\r\n” to comply with RFC 822)
*/
public string $CRLF = "\r\n";
/**
* Newline character. (Use “\r\n” to comply with RFC 822)
*/
public string $newline = "\r\n";
/**
* Enable BCC Batch Mode.
*/
public bool $BCCBatchMode = false;
/**
* Number of emails in each BCC batch
*/
public int $BCCBatchSize = 200;
/**
* Enable notify message from server
*/
public bool $DSN = false;
}

92
app/Config/Encryption.php Normal file
View File

@ -0,0 +1,92 @@
<?php
namespace Config;
use CodeIgniter\Config\BaseConfig;
/**
* Encryption configuration.
*
* These are the settings used for encryption, if you don't pass a parameter
* array to the encrypter for creation/initialization.
*/
class Encryption extends BaseConfig
{
/**
* --------------------------------------------------------------------------
* Encryption Key Starter
* --------------------------------------------------------------------------
*
* If you use the Encryption class you must set an encryption key (seed).
* You need to ensure it is long enough for the cipher and mode you plan to use.
* See the user guide for more info.
*/
public string $key = '';
/**
* --------------------------------------------------------------------------
* Encryption Driver to Use
* --------------------------------------------------------------------------
*
* One of the supported encryption drivers.
*
* Available drivers:
* - OpenSSL
* - Sodium
*/
public string $driver = 'OpenSSL';
/**
* --------------------------------------------------------------------------
* SodiumHandler's Padding Length in Bytes
* --------------------------------------------------------------------------
*
* This is the number of bytes that will be padded to the plaintext message
* before it is encrypted. This value should be greater than zero.
*
* See the user guide for more information on padding.
*/
public int $blockSize = 16;
/**
* --------------------------------------------------------------------------
* Encryption digest
* --------------------------------------------------------------------------
*
* HMAC digest to use, e.g. 'SHA512' or 'SHA256'. Default value is 'SHA512'.
*/
public string $digest = 'SHA512';
/**
* Whether the cipher-text should be raw. If set to false, then it will be base64 encoded.
* This setting is only used by OpenSSLHandler.
*
* Set to false for CI3 Encryption compatibility.
*/
public bool $rawData = true;
/**
* Encryption key info.
* This setting is only used by OpenSSLHandler.
*
* Set to 'encryption' for CI3 Encryption compatibility.
*/
public string $encryptKeyInfo = '';
/**
* Authentication key info.
* This setting is only used by OpenSSLHandler.
*
* Set to 'authentication' for CI3 Encryption compatibility.
*/
public string $authKeyInfo = '';
/**
* Cipher to use.
* This setting is only used by OpenSSLHandler.
*
* Set to 'AES-128-CBC' to decrypt encrypted data that encrypted
* by CI3 Encryption default configuration.
*/
public string $cipher = 'AES-256-CTR';
}

55
app/Config/Events.php Normal file
View File

@ -0,0 +1,55 @@
<?php
namespace Config;
use CodeIgniter\Events\Events;
use CodeIgniter\Exceptions\FrameworkException;
use CodeIgniter\HotReloader\HotReloader;
/*
* --------------------------------------------------------------------
* Application Events
* --------------------------------------------------------------------
* Events allow you to tap into the execution of the program without
* modifying or extending core files. This file provides a central
* location to define your events, though they can always be added
* at run-time, also, if needed.
*
* You create code that can execute by subscribing to events with
* the 'on()' method. This accepts any form of callable, including
* Closures, that will be executed when the event is triggered.
*
* Example:
* Events::on('create', [$myInstance, 'myMethod']);
*/
Events::on('pre_system', static function (): void {
if (ENVIRONMENT !== 'testing') {
if (ini_get('zlib.output_compression')) {
throw FrameworkException::forEnabledZlibOutputCompression();
}
while (ob_get_level() > 0) {
ob_end_flush();
}
ob_start(static fn ($buffer) => $buffer);
}
/*
* --------------------------------------------------------------------
* Debug Toolbar Listeners.
* --------------------------------------------------------------------
* If you delete, they will no longer be collected.
*/
if (CI_DEBUG && ! is_cli()) {
Events::on('DBQuery', 'CodeIgniter\Debug\Toolbar\Collectors\Database::collect');
service('toolbar')->respond();
// Hot Reload route - for framework use on the hot reloader.
if (ENVIRONMENT === 'development') {
service('routes')->get('__hot-reload', static function (): void {
(new HotReloader())->run();
});
}
}
});

106
app/Config/Exceptions.php Normal file
View File

@ -0,0 +1,106 @@
<?php
namespace Config;
use CodeIgniter\Config\BaseConfig;
use CodeIgniter\Debug\ExceptionHandler;
use CodeIgniter\Debug\ExceptionHandlerInterface;
use Psr\Log\LogLevel;
use Throwable;
/**
* Setup how the exception handler works.
*/
class Exceptions extends BaseConfig
{
/**
* --------------------------------------------------------------------------
* LOG EXCEPTIONS?
* --------------------------------------------------------------------------
* If true, then exceptions will be logged
* through Services::Log.
*
* Default: true
*/
public bool $log = true;
/**
* --------------------------------------------------------------------------
* DO NOT LOG STATUS CODES
* --------------------------------------------------------------------------
* Any status codes here will NOT be logged if logging is turned on.
* By default, only 404 (Page Not Found) exceptions are ignored.
*
* @var list<int>
*/
public array $ignoreCodes = [404];
/**
* --------------------------------------------------------------------------
* Error Views Path
* --------------------------------------------------------------------------
* This is the path to the directory that contains the 'cli' and 'html'
* directories that hold the views used to generate errors.
*
* Default: APPPATH.'Views/errors'
*/
public string $errorViewPath = APPPATH . 'Views/errors';
/**
* --------------------------------------------------------------------------
* HIDE FROM DEBUG TRACE
* --------------------------------------------------------------------------
* Any data that you would like to hide from the debug trace.
* In order to specify 2 levels, use "/" to separate.
* ex. ['server', 'setup/password', 'secret_token']
*
* @var list<string>
*/
public array $sensitiveDataInTrace = [];
/**
* --------------------------------------------------------------------------
* WHETHER TO THROW AN EXCEPTION ON DEPRECATED ERRORS
* --------------------------------------------------------------------------
* If set to `true`, DEPRECATED errors are only logged and no exceptions are
* thrown. This option also works for user deprecations.
*/
public bool $logDeprecations = true;
/**
* --------------------------------------------------------------------------
* LOG LEVEL THRESHOLD FOR DEPRECATIONS
* --------------------------------------------------------------------------
* If `$logDeprecations` is set to `true`, this sets the log level
* to which the deprecation will be logged. This should be one of the log
* levels recognized by PSR-3.
*
* The related `Config\Logger::$threshold` should be adjusted, if needed,
* to capture logging the deprecations.
*/
public string $deprecationLogLevel = LogLevel::WARNING;
/*
* DEFINE THE HANDLERS USED
* --------------------------------------------------------------------------
* Given the HTTP status code, returns exception handler that
* should be used to deal with this error. By default, it will run CodeIgniter's
* default handler and display the error information in the expected format
* for CLI, HTTP, or AJAX requests, as determined by is_cli() and the expected
* response format.
*
* Custom handlers can be returned if you want to handle one or more specific
* error codes yourself like:
*
* if (in_array($statusCode, [400, 404, 500])) {
* return new \App\Libraries\MyExceptionHandler();
* }
* if ($exception instanceOf PageNotFoundException) {
* return new \App\Libraries\MyExceptionHandler();
* }
*/
public function handler(int $statusCode, Throwable $exception): ExceptionHandlerInterface
{
return new ExceptionHandler($this);
}
}

37
app/Config/Feature.php Normal file
View File

@ -0,0 +1,37 @@
<?php
namespace Config;
use CodeIgniter\Config\BaseConfig;
/**
* Enable/disable backward compatibility breaking features.
*/
class Feature extends BaseConfig
{
/**
* Use improved new auto routing instead of the legacy version.
*/
public bool $autoRoutesImproved = true;
/**
* Use filter execution order in 4.4 or before.
*/
public bool $oldFilterOrder = false;
/**
* The behavior of `limit(0)` in Query Builder.
*
* If true, `limit(0)` returns all records. (the behavior of 4.4.x or before in version 4.x.)
* If false, `limit(0)` returns no records. (the behavior of 3.1.9 or later in version 3.x.)
*/
public bool $limitZeroAsAll = true;
/**
* Use strict location negotiation.
*
* By default, the locale is selected based on a loose comparison of the language code (ISO 639-1)
* Enabling strict comparison will also consider the region code (ISO 3166-1 alpha-2).
*/
public bool $strictLocaleNegotiation = false;
}

110
app/Config/Filters.php Normal file
View File

@ -0,0 +1,110 @@
<?php
namespace Config;
use CodeIgniter\Config\Filters as BaseFilters;
use CodeIgniter\Filters\Cors;
use CodeIgniter\Filters\CSRF;
use CodeIgniter\Filters\DebugToolbar;
use CodeIgniter\Filters\ForceHTTPS;
use CodeIgniter\Filters\Honeypot;
use CodeIgniter\Filters\InvalidChars;
use CodeIgniter\Filters\PageCache;
use CodeIgniter\Filters\PerformanceMetrics;
use CodeIgniter\Filters\SecureHeaders;
class Filters extends BaseFilters
{
/**
* Configures aliases for Filter classes to
* make reading things nicer and simpler.
*
* @var array<string, class-string|list<class-string>>
*
* [filter_name => classname]
* or [filter_name => [classname1, classname2, ...]]
*/
public array $aliases = [
'csrf' => CSRF::class,
'toolbar' => DebugToolbar::class,
'honeypot' => Honeypot::class,
'invalidchars' => InvalidChars::class,
'secureheaders' => SecureHeaders::class,
'cors' => Cors::class,
'forcehttps' => ForceHTTPS::class,
'pagecache' => PageCache::class,
'performance' => PerformanceMetrics::class,
];
/**
* List of special required filters.
*
* The filters listed here are special. They are applied before and after
* other kinds of filters, and always applied even if a route does not exist.
*
* Filters set by default provide framework functionality. If removed,
* those functions will no longer work.
*
* @see https://codeigniter.com/user_guide/incoming/filters.html#provided-filters
*
* @var array{before: list<string>, after: list<string>}
*/
public array $required = [
'before' => [
'forcehttps', // Force Global Secure Requests
'pagecache', // Web Page Caching
],
'after' => [
'pagecache', // Web Page Caching
'performance', // Performance Metrics
'toolbar', // Debug Toolbar
],
];
/**
* List of filter aliases that are always
* applied before and after every request.
*
* @var array{
* before: array<string, array{except: list<string>|string}>|list<string>,
* after: array<string, array{except: list<string>|string}>|list<string>
* }
*/
public array $globals = [
'before' => [
// 'honeypot',
// 'csrf',
// 'invalidchars',
],
'after' => [
// 'honeypot',
// 'secureheaders',
],
];
/**
* List of filter aliases that works on a
* particular HTTP method (GET, POST, etc.).
*
* Example:
* 'POST' => ['foo', 'bar']
*
* If you use this, you should disable auto-routing because auto-routing
* permits any HTTP method to access a controller. Accessing the controller
* with a method you don't expect could bypass the filter.
*
* @var array<string, list<string>>
*/
public array $methods = [];
/**
* List of filter aliases that should run on any
* before or after URI patterns.
*
* Example:
* 'isLoggedIn' => ['before' => ['account/*', 'profiles/*']]
*
* @var array<string, array<string, list<string>>>
*/
public array $filters = [];
}

View File

@ -0,0 +1,12 @@
<?php
namespace Config;
use CodeIgniter\Config\ForeignCharacters as BaseForeignCharacters;
/**
* @immutable
*/
class ForeignCharacters extends BaseForeignCharacters
{
}

64
app/Config/Format.php Normal file
View File

@ -0,0 +1,64 @@
<?php
namespace Config;
use CodeIgniter\Config\BaseConfig;
use CodeIgniter\Format\JSONFormatter;
use CodeIgniter\Format\XMLFormatter;
class Format extends BaseConfig
{
/**
* --------------------------------------------------------------------------
* Available Response Formats
* --------------------------------------------------------------------------
*
* When you perform content negotiation with the request, these are the
* available formats that your application supports. This is currently
* only used with the API\ResponseTrait. A valid Formatter must exist
* for the specified format.
*
* These formats are only checked when the data passed to the respond()
* method is an array.
*
* @var list<string>
*/
public array $supportedResponseFormats = [
'application/json',
'application/xml', // machine-readable XML
'text/xml', // human-readable XML
];
/**
* --------------------------------------------------------------------------
* Formatters
* --------------------------------------------------------------------------
*
* Lists the class to use to format responses with of a particular type.
* For each mime type, list the class that should be used. Formatters
* can be retrieved through the getFormatter() method.
*
* @var array<string, string>
*/
public array $formatters = [
'application/json' => JSONFormatter::class,
'application/xml' => XMLFormatter::class,
'text/xml' => XMLFormatter::class,
];
/**
* --------------------------------------------------------------------------
* Formatters Options
* --------------------------------------------------------------------------
*
* Additional Options to adjust default formatters behaviour.
* For each mime type, list the additional options that should be used.
*
* @var array<string, int>
*/
public array $formatterOptions = [
'application/json' => JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES,
'application/xml' => 0,
'text/xml' => 0,
];
}

44
app/Config/Generators.php Normal file
View File

@ -0,0 +1,44 @@
<?php
namespace Config;
use CodeIgniter\Config\BaseConfig;
class Generators extends BaseConfig
{
/**
* --------------------------------------------------------------------------
* Generator Commands' Views
* --------------------------------------------------------------------------
*
* This array defines the mapping of generator commands to the view files
* they are using. If you need to customize them for your own, copy these
* view files in your own folder and indicate the location here.
*
* You will notice that the views have special placeholders enclosed in
* curly braces `{...}`. These placeholders are used internally by the
* generator commands in processing replacements, thus you are warned
* not to delete them or modify the names. If you will do so, you may
* end up disrupting the scaffolding process and throw errors.
*
* YOU HAVE BEEN WARNED!
*
* @var array<string, array<string, string>|string>
*/
public array $views = [
'make:cell' => [
'class' => 'CodeIgniter\Commands\Generators\Views\cell.tpl.php',
'view' => 'CodeIgniter\Commands\Generators\Views\cell_view.tpl.php',
],
'make:command' => 'CodeIgniter\Commands\Generators\Views\command.tpl.php',
'make:config' => 'CodeIgniter\Commands\Generators\Views\config.tpl.php',
'make:controller' => 'CodeIgniter\Commands\Generators\Views\controller.tpl.php',
'make:entity' => 'CodeIgniter\Commands\Generators\Views\entity.tpl.php',
'make:filter' => 'CodeIgniter\Commands\Generators\Views\filter.tpl.php',
'make:migration' => 'CodeIgniter\Commands\Generators\Views\migration.tpl.php',
'make:model' => 'CodeIgniter\Commands\Generators\Views\model.tpl.php',
'make:seeder' => 'CodeIgniter\Commands\Generators\Views\seeder.tpl.php',
'make:validation' => 'CodeIgniter\Commands\Generators\Views\validation.tpl.php',
'session:migration' => 'CodeIgniter\Commands\Generators\Views\migration.tpl.php',
];
}

42
app/Config/Honeypot.php Normal file
View File

@ -0,0 +1,42 @@
<?php
namespace Config;
use CodeIgniter\Config\BaseConfig;
class Honeypot extends BaseConfig
{
/**
* Makes Honeypot visible or not to human
*/
public bool $hidden = true;
/**
* Honeypot Label Content
*/
public string $label = 'Fill This Field';
/**
* Honeypot Field Name
*/
public string $name = 'honeypot';
/**
* Honeypot HTML Template
*/
public string $template = '<label>{label}</label><input type="text" name="{name}" value="">';
/**
* Honeypot container
*
* If you enabled CSP, you can remove `style="display:none"`.
*/
public string $container = '<div style="display:none">{template}</div>';
/**
* The id attribute for Honeypot container tag
*
* Used when CSP is enabled.
*/
public string $containerId = 'hpc';
}

31
app/Config/Images.php Normal file
View File

@ -0,0 +1,31 @@
<?php
namespace Config;
use CodeIgniter\Config\BaseConfig;
use CodeIgniter\Images\Handlers\GDHandler;
use CodeIgniter\Images\Handlers\ImageMagickHandler;
class Images extends BaseConfig
{
/**
* Default handler used if no other handler is specified.
*/
public string $defaultHandler = 'gd';
/**
* The path to the image library.
* Required for ImageMagick, GraphicsMagick, or NetPBM.
*/
public string $libraryPath = '/usr/local/bin/convert';
/**
* The available handler classes.
*
* @var array<string, string>
*/
public array $handlers = [
'gd' => GDHandler::class,
'imagick' => ImageMagickHandler::class,
];
}

63
app/Config/Kint.php Normal file
View File

@ -0,0 +1,63 @@
<?php
namespace Config;
use Kint\Parser\ConstructablePluginInterface;
use Kint\Renderer\Rich\TabPluginInterface;
use Kint\Renderer\Rich\ValuePluginInterface;
/**
* --------------------------------------------------------------------------
* Kint
* --------------------------------------------------------------------------
*
* We use Kint's `RichRenderer` and `CLIRenderer`. This area contains options
* that you can set to customize how Kint works for you.
*
* @see https://kint-php.github.io/kint/ for details on these settings.
*/
class Kint
{
/*
|--------------------------------------------------------------------------
| Global Settings
|--------------------------------------------------------------------------
*/
/**
* @var list<class-string<ConstructablePluginInterface>|ConstructablePluginInterface>|null
*/
public $plugins;
public int $maxDepth = 6;
public bool $displayCalledFrom = true;
public bool $expanded = false;
/*
|--------------------------------------------------------------------------
| RichRenderer Settings
|--------------------------------------------------------------------------
*/
public string $richTheme = 'aante-light.css';
public bool $richFolder = false;
/**
* @var array<string, class-string<ValuePluginInterface>>|null
*/
public $richObjectPlugins;
/**
* @var array<string, class-string<TabPluginInterface>>|null
*/
public $richTabPlugins;
/*
|--------------------------------------------------------------------------
| CLI Settings
|--------------------------------------------------------------------------
*/
public bool $cliColors = true;
public bool $cliForceUTF8 = false;
public bool $cliDetectWidth = true;
public int $cliMinWidth = 40;
}

151
app/Config/Logger.php Normal file
View File

@ -0,0 +1,151 @@
<?php
namespace Config;
use CodeIgniter\Config\BaseConfig;
use CodeIgniter\Log\Handlers\FileHandler;
use CodeIgniter\Log\Handlers\HandlerInterface;
class Logger extends BaseConfig
{
/**
* --------------------------------------------------------------------------
* Error Logging Threshold
* --------------------------------------------------------------------------
*
* You can enable error logging by setting a threshold over zero. The
* threshold determines what gets logged. Any values below or equal to the
* threshold will be logged.
*
* Threshold options are:
*
* - 0 = Disables logging, Error logging TURNED OFF
* - 1 = Emergency Messages - System is unusable
* - 2 = Alert Messages - Action Must Be Taken Immediately
* - 3 = Critical Messages - Application component unavailable, unexpected exception.
* - 4 = Runtime Errors - Don't need immediate action, but should be monitored.
* - 5 = Warnings - Exceptional occurrences that are not errors.
* - 6 = Notices - Normal but significant events.
* - 7 = Info - Interesting events, like user logging in, etc.
* - 8 = Debug - Detailed debug information.
* - 9 = All Messages
*
* You can also pass an array with threshold levels to show individual error types
*
* array(1, 2, 3, 8) = Emergency, Alert, Critical, and Debug messages
*
* For a live site you'll usually enable Critical or higher (3) to be logged otherwise
* your log files will fill up very fast.
*
* @var int|list<int>
*/
public $threshold = (ENVIRONMENT === 'production') ? 4 : 9;
/**
* --------------------------------------------------------------------------
* Date Format for Logs
* --------------------------------------------------------------------------
*
* Each item that is logged has an associated date. You can use PHP date
* codes to set your own date formatting
*/
public string $dateFormat = 'Y-m-d H:i:s';
/**
* --------------------------------------------------------------------------
* Log Handlers
* --------------------------------------------------------------------------
*
* The logging system supports multiple actions to be taken when something
* is logged. This is done by allowing for multiple Handlers, special classes
* designed to write the log to their chosen destinations, whether that is
* a file on the getServer, a cloud-based service, or even taking actions such
* as emailing the dev team.
*
* Each handler is defined by the class name used for that handler, and it
* MUST implement the `CodeIgniter\Log\Handlers\HandlerInterface` interface.
*
* The value of each key is an array of configuration items that are sent
* to the constructor of each handler. The only required configuration item
* is the 'handles' element, which must be an array of integer log levels.
* This is most easily handled by using the constants defined in the
* `Psr\Log\LogLevel` class.
*
* Handlers are executed in the order defined in this array, starting with
* the handler on top and continuing down.
*
* @var array<class-string<HandlerInterface>, array<string, int|list<string>|string>>
*/
public array $handlers = [
/*
* --------------------------------------------------------------------
* File Handler
* --------------------------------------------------------------------
*/
FileHandler::class => [
// The log levels that this handler will handle.
'handles' => [
'critical',
'alert',
'emergency',
'debug',
'error',
'info',
'notice',
'warning',
],
/*
* The default filename extension for log files.
* An extension of 'php' allows for protecting the log files via basic
* scripting, when they are to be stored under a publicly accessible directory.
*
* NOTE: Leaving it blank will default to 'log'.
*/
'fileExtension' => '',
/*
* The file system permissions to be applied on newly created log files.
*
* IMPORTANT: This MUST be an integer (no quotes) and you MUST use octal
* integer notation (i.e. 0700, 0644, etc.)
*/
'filePermissions' => 0644,
/*
* Logging Directory Path
*
* By default, logs are written to WRITEPATH . 'logs/'
* Specify a different destination here, if desired.
*/
'path' => '',
],
/*
* The ChromeLoggerHandler requires the use of the Chrome web browser
* and the ChromeLogger extension. Uncomment this block to use it.
*/
// 'CodeIgniter\Log\Handlers\ChromeLoggerHandler' => [
// /*
// * The log levels that this handler will handle.
// */
// 'handles' => ['critical', 'alert', 'emergency', 'debug',
// 'error', 'info', 'notice', 'warning'],
// ],
/*
* The ErrorlogHandler writes the logs to PHP's native `error_log()` function.
* Uncomment this block to use it.
*/
// 'CodeIgniter\Log\Handlers\ErrorlogHandler' => [
// /* The log levels this handler can handle. */
// 'handles' => ['critical', 'alert', 'emergency', 'debug', 'error', 'info', 'notice', 'warning'],
//
// /*
// * The message type where the error should go. Can be 0 or 4, or use the
// * class constants: `ErrorlogHandler::TYPE_OS` (0) or `ErrorlogHandler::TYPE_SAPI` (4)
// */
// 'messageType' => 0,
// ],
];
}

50
app/Config/Migrations.php Normal file
View File

@ -0,0 +1,50 @@
<?php
namespace Config;
use CodeIgniter\Config\BaseConfig;
class Migrations extends BaseConfig
{
/**
* --------------------------------------------------------------------------
* Enable/Disable Migrations
* --------------------------------------------------------------------------
*
* Migrations are enabled by default.
*
* You should enable migrations whenever you intend to do a schema migration
* and disable it back when you're done.
*/
public bool $enabled = true;
/**
* --------------------------------------------------------------------------
* Migrations Table
* --------------------------------------------------------------------------
*
* This is the name of the table that will store the current migrations state.
* When migrations runs it will store in a database table which migration
* files have already been run.
*/
public string $table = 'migrations';
/**
* --------------------------------------------------------------------------
* Timestamp Format
* --------------------------------------------------------------------------
*
* This is the format that will be used when creating new migrations
* using the CLI command:
* > php spark make:migration
*
* NOTE: if you set an unsupported format, migration runner will not find
* your migration files.
*
* Supported formats:
* - YmdHis_
* - Y-m-d-His_
* - Y_m_d_His_
*/
public string $timestampFormat = 'Y-m-d-His_';
}

534
app/Config/Mimes.php Normal file
View File

@ -0,0 +1,534 @@
<?php
namespace Config;
/**
* This file contains an array of mime types. It is used by the
* Upload class to help identify allowed file types.
*
* When more than one variation for an extension exist (like jpg, jpeg, etc)
* the most common one should be first in the array to aid the guess*
* methods. The same applies when more than one mime-type exists for a
* single extension.
*
* When working with mime types, please make sure you have the ´fileinfo´
* extension enabled to reliably detect the media types.
*/
class Mimes
{
/**
* Map of extensions to mime types.
*
* @var array<string, list<string>|string>
*/
public static array $mimes = [
'hqx' => [
'application/mac-binhex40',
'application/mac-binhex',
'application/x-binhex40',
'application/x-mac-binhex40',
],
'cpt' => 'application/mac-compactpro',
'csv' => [
'text/csv',
'text/x-comma-separated-values',
'text/comma-separated-values',
'application/vnd.ms-excel',
'application/x-csv',
'text/x-csv',
'application/csv',
'application/excel',
'application/vnd.msexcel',
'text/plain',
],
'bin' => [
'application/macbinary',
'application/mac-binary',
'application/octet-stream',
'application/x-binary',
'application/x-macbinary',
],
'dms' => 'application/octet-stream',
'lha' => 'application/octet-stream',
'lzh' => 'application/octet-stream',
'exe' => [
'application/octet-stream',
'application/vnd.microsoft.portable-executable',
'application/x-dosexec',
'application/x-msdownload',
],
'class' => 'application/octet-stream',
'psd' => [
'application/x-photoshop',
'image/vnd.adobe.photoshop',
],
'so' => 'application/octet-stream',
'sea' => 'application/octet-stream',
'dll' => 'application/octet-stream',
'oda' => 'application/oda',
'pdf' => [
'application/pdf',
'application/force-download',
'application/x-download',
],
'ai' => [
'application/pdf',
'application/postscript',
],
'eps' => 'application/postscript',
'ps' => 'application/postscript',
'smi' => 'application/smil',
'smil' => 'application/smil',
'mif' => 'application/vnd.mif',
'xls' => [
'application/vnd.ms-excel',
'application/msexcel',
'application/x-msexcel',
'application/x-ms-excel',
'application/x-excel',
'application/x-dos_ms_excel',
'application/xls',
'application/x-xls',
'application/excel',
'application/download',
'application/vnd.ms-office',
'application/msword',
],
'ppt' => [
'application/vnd.ms-powerpoint',
'application/powerpoint',
'application/vnd.ms-office',
'application/msword',
],
'pptx' => [
'application/vnd.openxmlformats-officedocument.presentationml.presentation',
],
'wbxml' => 'application/wbxml',
'wmlc' => 'application/wmlc',
'dcr' => 'application/x-director',
'dir' => 'application/x-director',
'dxr' => 'application/x-director',
'dvi' => 'application/x-dvi',
'gtar' => 'application/x-gtar',
'gz' => 'application/x-gzip',
'gzip' => 'application/x-gzip',
'php' => [
'application/x-php',
'application/x-httpd-php',
'application/php',
'text/php',
'text/x-php',
'application/x-httpd-php-source',
],
'php4' => 'application/x-httpd-php',
'php3' => 'application/x-httpd-php',
'phtml' => 'application/x-httpd-php',
'phps' => 'application/x-httpd-php-source',
'js' => [
'application/x-javascript',
'text/plain',
],
'swf' => 'application/x-shockwave-flash',
'sit' => 'application/x-stuffit',
'tar' => 'application/x-tar',
'tgz' => [
'application/x-tar',
'application/x-gzip-compressed',
],
'z' => 'application/x-compress',
'xhtml' => 'application/xhtml+xml',
'xht' => 'application/xhtml+xml',
'zip' => [
'application/x-zip',
'application/zip',
'application/x-zip-compressed',
'application/s-compressed',
'multipart/x-zip',
],
'rar' => [
'application/vnd.rar',
'application/x-rar',
'application/rar',
'application/x-rar-compressed',
],
'mid' => 'audio/midi',
'midi' => 'audio/midi',
'mpga' => 'audio/mpeg',
'mp2' => 'audio/mpeg',
'mp3' => [
'audio/mpeg',
'audio/mpg',
'audio/mpeg3',
'audio/mp3',
],
'aif' => [
'audio/x-aiff',
'audio/aiff',
],
'aiff' => [
'audio/x-aiff',
'audio/aiff',
],
'aifc' => 'audio/x-aiff',
'ram' => 'audio/x-pn-realaudio',
'rm' => 'audio/x-pn-realaudio',
'rpm' => 'audio/x-pn-realaudio-plugin',
'ra' => 'audio/x-realaudio',
'rv' => 'video/vnd.rn-realvideo',
'wav' => [
'audio/x-wav',
'audio/wave',
'audio/wav',
],
'bmp' => [
'image/bmp',
'image/x-bmp',
'image/x-bitmap',
'image/x-xbitmap',
'image/x-win-bitmap',
'image/x-windows-bmp',
'image/ms-bmp',
'image/x-ms-bmp',
'application/bmp',
'application/x-bmp',
'application/x-win-bitmap',
],
'gif' => 'image/gif',
'jpg' => [
'image/jpeg',
'image/pjpeg',
],
'jpeg' => [
'image/jpeg',
'image/pjpeg',
],
'jpe' => [
'image/jpeg',
'image/pjpeg',
],
'jp2' => [
'image/jp2',
'video/mj2',
'image/jpx',
'image/jpm',
],
'j2k' => [
'image/jp2',
'video/mj2',
'image/jpx',
'image/jpm',
],
'jpf' => [
'image/jp2',
'video/mj2',
'image/jpx',
'image/jpm',
],
'jpg2' => [
'image/jp2',
'video/mj2',
'image/jpx',
'image/jpm',
],
'jpx' => [
'image/jp2',
'video/mj2',
'image/jpx',
'image/jpm',
],
'jpm' => [
'image/jp2',
'video/mj2',
'image/jpx',
'image/jpm',
],
'mj2' => [
'image/jp2',
'video/mj2',
'image/jpx',
'image/jpm',
],
'mjp2' => [
'image/jp2',
'video/mj2',
'image/jpx',
'image/jpm',
],
'png' => [
'image/png',
'image/x-png',
],
'webp' => 'image/webp',
'tif' => 'image/tiff',
'tiff' => 'image/tiff',
'css' => [
'text/css',
'text/plain',
],
'html' => [
'text/html',
'text/plain',
],
'htm' => [
'text/html',
'text/plain',
],
'shtml' => [
'text/html',
'text/plain',
],
'txt' => 'text/plain',
'text' => 'text/plain',
'log' => [
'text/plain',
'text/x-log',
],
'rtx' => 'text/richtext',
'rtf' => 'text/rtf',
'xml' => [
'application/xml',
'text/xml',
'text/plain',
],
'xsl' => [
'application/xml',
'text/xsl',
'text/xml',
],
'mpeg' => 'video/mpeg',
'mpg' => 'video/mpeg',
'mpe' => 'video/mpeg',
'qt' => 'video/quicktime',
'mov' => 'video/quicktime',
'avi' => [
'video/x-msvideo',
'video/msvideo',
'video/avi',
'application/x-troff-msvideo',
],
'movie' => 'video/x-sgi-movie',
'doc' => [
'application/msword',
'application/vnd.ms-office',
],
'docx' => [
'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
'application/zip',
'application/msword',
'application/x-zip',
],
'dot' => [
'application/msword',
'application/vnd.ms-office',
],
'dotx' => [
'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
'application/zip',
'application/msword',
],
'xlsx' => [
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
'application/zip',
'application/vnd.ms-excel',
'application/msword',
'application/x-zip',
],
'xlsb' => 'application/vnd.ms-excel.sheet.binary.macroEnabled.12',
'xlsm' => 'application/vnd.ms-excel.sheet.macroEnabled.12',
'word' => [
'application/msword',
'application/octet-stream',
],
'xl' => 'application/excel',
'eml' => 'message/rfc822',
'json' => [
'application/json',
'text/json',
],
'pem' => [
'application/x-x509-user-cert',
'application/x-pem-file',
'application/octet-stream',
],
'p10' => [
'application/x-pkcs10',
'application/pkcs10',
],
'p12' => 'application/x-pkcs12',
'p7a' => 'application/x-pkcs7-signature',
'p7c' => [
'application/pkcs7-mime',
'application/x-pkcs7-mime',
],
'p7m' => [
'application/pkcs7-mime',
'application/x-pkcs7-mime',
],
'p7r' => 'application/x-pkcs7-certreqresp',
'p7s' => 'application/pkcs7-signature',
'crt' => [
'application/x-x509-ca-cert',
'application/x-x509-user-cert',
'application/pkix-cert',
],
'crl' => [
'application/pkix-crl',
'application/pkcs-crl',
],
'der' => 'application/x-x509-ca-cert',
'kdb' => 'application/octet-stream',
'pgp' => 'application/pgp',
'gpg' => 'application/gpg-keys',
'sst' => 'application/octet-stream',
'csr' => 'application/octet-stream',
'rsa' => 'application/x-pkcs7',
'cer' => [
'application/pkix-cert',
'application/x-x509-ca-cert',
],
'3g2' => 'video/3gpp2',
'3gp' => [
'video/3gp',
'video/3gpp',
],
'mp4' => 'video/mp4',
'm4a' => 'audio/x-m4a',
'f4v' => [
'video/mp4',
'video/x-f4v',
],
'flv' => 'video/x-flv',
'webm' => 'video/webm',
'aac' => 'audio/x-acc',
'm4u' => 'application/vnd.mpegurl',
'm3u' => 'text/plain',
'xspf' => 'application/xspf+xml',
'vlc' => 'application/videolan',
'wmv' => [
'video/x-ms-wmv',
'video/x-ms-asf',
],
'au' => 'audio/x-au',
'ac3' => 'audio/ac3',
'flac' => 'audio/x-flac',
'ogg' => [
'audio/ogg',
'video/ogg',
'application/ogg',
],
'kmz' => [
'application/vnd.google-earth.kmz',
'application/zip',
'application/x-zip',
],
'kml' => [
'application/vnd.google-earth.kml+xml',
'application/xml',
'text/xml',
],
'ics' => 'text/calendar',
'ical' => 'text/calendar',
'zsh' => 'text/x-scriptzsh',
'7zip' => [
'application/x-compressed',
'application/x-zip-compressed',
'application/zip',
'multipart/x-zip',
],
'cdr' => [
'application/cdr',
'application/coreldraw',
'application/x-cdr',
'application/x-coreldraw',
'image/cdr',
'image/x-cdr',
'zz-application/zz-winassoc-cdr',
],
'wma' => [
'audio/x-ms-wma',
'video/x-ms-asf',
],
'jar' => [
'application/java-archive',
'application/x-java-application',
'application/x-jar',
'application/x-compressed',
],
'svg' => [
'image/svg+xml',
'image/svg',
'application/xml',
'text/xml',
],
'vcf' => 'text/x-vcard',
'srt' => [
'text/srt',
'text/plain',
],
'vtt' => [
'text/vtt',
'text/plain',
],
'ico' => [
'image/x-icon',
'image/x-ico',
'image/vnd.microsoft.icon',
],
'stl' => [
'application/sla',
'application/vnd.ms-pki.stl',
'application/x-navistyle',
'model/stl',
'application/octet-stream',
],
];
/**
* Attempts to determine the best mime type for the given file extension.
*
* @return string|null The mime type found, or none if unable to determine.
*/
public static function guessTypeFromExtension(string $extension)
{
$extension = trim(strtolower($extension), '. ');
if (! array_key_exists($extension, static::$mimes)) {
return null;
}
return is_array(static::$mimes[$extension]) ? static::$mimes[$extension][0] : static::$mimes[$extension];
}
/**
* Attempts to determine the best file extension for a given mime type.
*
* @param string|null $proposedExtension - default extension (in case there is more than one with the same mime type)
*
* @return string|null The extension determined, or null if unable to match.
*/
public static function guessExtensionFromType(string $type, ?string $proposedExtension = null)
{
$type = trim(strtolower($type), '. ');
$proposedExtension = trim(strtolower($proposedExtension ?? ''));
if (
$proposedExtension !== ''
&& array_key_exists($proposedExtension, static::$mimes)
&& in_array($type, (array) static::$mimes[$proposedExtension], true)
) {
// The detected mime type matches with the proposed extension.
return $proposedExtension;
}
// Reverse check the mime type list if no extension was proposed.
// This search is order sensitive!
foreach (static::$mimes as $ext => $types) {
if (in_array($type, (array) $types, true)) {
return $ext;
}
}
return null;
}
}

82
app/Config/Modules.php Normal file
View File

@ -0,0 +1,82 @@
<?php
namespace Config;
use CodeIgniter\Modules\Modules as BaseModules;
/**
* Modules Configuration.
*
* NOTE: This class is required prior to Autoloader instantiation,
* and does not extend BaseConfig.
*/
class Modules extends BaseModules
{
/**
* --------------------------------------------------------------------------
* Enable Auto-Discovery?
* --------------------------------------------------------------------------
*
* If true, then auto-discovery will happen across all elements listed in
* $aliases below. If false, no auto-discovery will happen at all,
* giving a slight performance boost.
*
* @var bool
*/
public $enabled = true;
/**
* --------------------------------------------------------------------------
* Enable Auto-Discovery Within Composer Packages?
* --------------------------------------------------------------------------
*
* If true, then auto-discovery will happen across all namespaces loaded
* by Composer, as well as the namespaces configured locally.
*
* @var bool
*/
public $discoverInComposer = true;
/**
* The Composer package list for Auto-Discovery
* This setting is optional.
*
* E.g.:
* [
* 'only' => [
* // List up all packages to auto-discover
* 'codeigniter4/shield',
* ],
* ]
* or
* [
* 'exclude' => [
* // List up packages to exclude.
* 'pestphp/pest',
* ],
* ]
*
* @var array{only?: list<string>, exclude?: list<string>}
*/
public $composerPackages = [];
/**
* --------------------------------------------------------------------------
* Auto-Discovery Rules
* --------------------------------------------------------------------------
*
* Aliases list of all discovery classes that will be active and used during
* the current application request.
*
* If it is not listed, only the base application elements will be used.
*
* @var list<string>
*/
public $aliases = [
'events',
'filters',
'registrars',
'routes',
'services',
];
}

30
app/Config/Optimize.php Normal file
View File

@ -0,0 +1,30 @@
<?php
namespace Config;
/**
* Optimization Configuration.
*
* NOTE: This class does not extend BaseConfig for performance reasons.
* So you cannot replace the property values with Environment Variables.
*/
class Optimize
{
/**
* --------------------------------------------------------------------------
* Config Caching
* --------------------------------------------------------------------------
*
* @see https://codeigniter.com/user_guide/concepts/factories.html#config-caching
*/
public bool $configCacheEnabled = false;
/**
* --------------------------------------------------------------------------
* Config Caching
* --------------------------------------------------------------------------
*
* @see https://codeigniter.com/user_guide/concepts/autoloader.html#file-locator-caching
*/
public bool $locatorCacheEnabled = false;
}

37
app/Config/Pager.php Normal file
View File

@ -0,0 +1,37 @@
<?php
namespace Config;
use CodeIgniter\Config\BaseConfig;
class Pager extends BaseConfig
{
/**
* --------------------------------------------------------------------------
* Templates
* --------------------------------------------------------------------------
*
* Pagination links are rendered out using views to configure their
* appearance. This array contains aliases and the view names to
* use when rendering the links.
*
* Within each view, the Pager object will be available as $pager,
* and the desired group as $pagerGroup;
*
* @var array<string, string>
*/
public array $templates = [
'default_full' => 'CodeIgniter\Pager\Views\default_full',
'default_simple' => 'CodeIgniter\Pager\Views\default_simple',
'default_head' => 'CodeIgniter\Pager\Views\default_head',
];
/**
* --------------------------------------------------------------------------
* Items Per Page
* --------------------------------------------------------------------------
*
* The default number of results shown in a single page.
*/
public int $perPage = 20;
}

78
app/Config/Paths.php Normal file
View File

@ -0,0 +1,78 @@
<?php
namespace Config;
/**
* Paths
*
* Holds the paths that are used by the system to
* locate the main directories, app, system, etc.
*
* Modifying these allows you to restructure your application,
* share a system folder between multiple applications, and more.
*
* All paths are relative to the project's root folder.
*
* NOTE: This class is required prior to Autoloader instantiation,
* and does not extend BaseConfig.
*/
class Paths
{
/**
* ---------------------------------------------------------------
* SYSTEM FOLDER NAME
* ---------------------------------------------------------------
*
* This must contain the name of your "system" folder. Include
* the path if the folder is not in the same directory as this file.
*/
public string $systemDirectory = __DIR__ . '/../../vendor/codeigniter4/framework/system';
/**
* ---------------------------------------------------------------
* APPLICATION FOLDER NAME
* ---------------------------------------------------------------
*
* If you want this front controller to use a different "app"
* folder than the default one you can set its name here. The folder
* can also be renamed or relocated anywhere on your server. If
* you do, use a full server path.
*
* @see http://codeigniter.com/user_guide/general/managing_apps.html
*/
public string $appDirectory = __DIR__ . '/..';
/**
* ---------------------------------------------------------------
* WRITABLE DIRECTORY NAME
* ---------------------------------------------------------------
*
* This variable must contain the name of your "writable" directory.
* The writable directory allows you to group all directories that
* need write permission to a single place that can be tucked away
* for maximum security, keeping it out of the app and/or
* system directories.
*/
public string $writableDirectory = __DIR__ . '/../../writable';
/**
* ---------------------------------------------------------------
* TESTS DIRECTORY NAME
* ---------------------------------------------------------------
*
* This variable must contain the name of your "tests" directory.
*/
public string $testsDirectory = __DIR__ . '/../../tests';
/**
* ---------------------------------------------------------------
* VIEW DIRECTORY NAME
* ---------------------------------------------------------------
*
* This variable must contain the name of the directory that
* contains the view files used by your application. By
* default this is in `app/Views`. This value
* is used when no value is provided to `Services::renderer()`.
*/
public string $viewDirectory = __DIR__ . '/../Views';
}

28
app/Config/Publisher.php Normal file
View File

@ -0,0 +1,28 @@
<?php
namespace Config;
use CodeIgniter\Config\Publisher as BasePublisher;
/**
* Publisher Configuration
*
* Defines basic security restrictions for the Publisher class
* to prevent abuse by injecting malicious files into a project.
*/
class Publisher extends BasePublisher
{
/**
* A list of allowed destinations with a (pseudo-)regex
* of allowed files for each destination.
* Attempts to publish to directories not in this list will
* result in a PublisherException. Files that do no fit the
* pattern will cause copy/merge to fail.
*
* @var array<string, string>
*/
public $restrictions = [
ROOTPATH => '*',
FCPATH => '#\.(s?css|js|map|html?|xml|json|webmanifest|ttf|eot|woff2?|gif|jpe?g|tiff?|png|webp|bmp|ico|svg)$#i',
];
}

43
app/Config/Routes.php Normal file
View File

@ -0,0 +1,43 @@
<?php
use CodeIgniter\Router\RouteCollection;
/**
* @var RouteCollection $routes
*/
$routes->get('/', 'PageController::dashboard');
$routes->get('/dept', 'PageController::dept');
$routes->get('/test', 'PageController::test');
$routes->get('/control', 'PageController::control');
$routes->get('/entry', 'PageController::entry');
$routes->get('/entry/daily', 'PageController::entryDaily');
$routes->get('/report', 'PageController::report');
$routes->get('/report/view', 'PageController::reportView');
$routes->group('api', function ($routes) {
$routes->get('dept', 'Api\DeptApiController::index');
$routes->get('dept/(:num)', 'Api\DeptApiController::show/$1');
$routes->post('dept', 'Api\DeptApiController::store');
$routes->put('dept/(:num)', 'Api\DeptApiController::update/$1');
$routes->delete('dept/(:num)', 'Api\DeptApiController::delete/$1');
$routes->get('test', 'Api\TestApiController::index');
$routes->get('test/(:num)', 'Api\TestApiController::show/$1');
$routes->post('test', 'Api\TestApiController::store');
$routes->put('test/(:num)', 'Api\TestApiController::update/$1');
$routes->delete('test/(:num)', 'Api\TestApiController::delete/$1');
$routes->get('control', 'Api\ControlApiController::index');
$routes->get('control/(:num)', 'Api\ControlApiController::show/$1');
$routes->get('control/(:num)/tests', 'Api\ControlApiController::getTests/$1');
$routes->post('control', 'Api\ControlApiController::store');
$routes->put('control/(:num)', 'Api\ControlApiController::update/$1');
$routes->delete('control/(:num)', 'Api\ControlApiController::delete/$1');
$routes->get('entry/controls', 'Api\EntryApiController::getControls');
$routes->get('entry/tests', 'Api\EntryApiController::getTests');
$routes->post('entry/daily', 'Api\EntryApiController::saveDaily');
$routes->post('entry/monthly', 'Api\EntryApiController::saveMonthly');
$routes->post('entry/comment', 'Api\EntryApiController::saveComment');
});

140
app/Config/Routing.php Normal file
View File

@ -0,0 +1,140 @@
<?php
/**
* This file is part of CodeIgniter 4 framework.
*
* (c) CodeIgniter Foundation <admin@codeigniter.com>
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace Config;
use CodeIgniter\Config\Routing as BaseRouting;
/**
* Routing configuration
*/
class Routing extends BaseRouting
{
/**
* For Defined Routes.
* An array of files that contain route definitions.
* Route files are read in order, with the first match
* found taking precedence.
*
* Default: APPPATH . 'Config/Routes.php'
*
* @var list<string>
*/
public array $routeFiles = [
APPPATH . 'Config/Routes.php',
];
/**
* For Defined Routes and Auto Routing.
* The default namespace to use for Controllers when no other
* namespace has been specified.
*
* Default: 'App\Controllers'
*/
public string $defaultNamespace = 'App\Controllers';
/**
* For Auto Routing.
* The default controller to use when no other controller has been
* specified.
*
* Default: 'Home'
*/
public string $defaultController = 'Home';
/**
* For Defined Routes and Auto Routing.
* The default method to call on the controller when no other
* method has been set in the route.
*
* Default: 'index'
*/
public string $defaultMethod = 'index';
/**
* For Auto Routing.
* Whether to translate dashes in URIs for controller/method to underscores.
* Primarily useful when using the auto-routing.
*
* Default: false
*/
public bool $translateURIDashes = false;
/**
* Sets the class/method that should be called if routing doesn't
* find a match. It can be the controller/method name like: Users::index
*
* This setting is passed to the Router class and handled there.
*
* If you want to use a closure, you will have to set it in the
* routes file by calling:
*
* $routes->set404Override(function() {
* // Do something here
* });
*
* Example:
* public $override404 = 'App\Errors::show404';
*/
public ?string $override404 = null;
/**
* If TRUE, the system will attempt to match the URI against
* Controllers by matching each segment against folders/files
* in APPPATH/Controllers, when a match wasn't found against
* defined routes.
*
* If FALSE, will stop searching and do NO automatic routing.
*/
public bool $autoRoute = false;
/**
* For Defined Routes.
* If TRUE, will enable the use of the 'prioritize' option
* when defining routes.
*
* Default: false
*/
public bool $prioritize = false;
/**
* For Defined Routes.
* If TRUE, matched multiple URI segments will be passed as one parameter.
*
* Default: false
*/
public bool $multipleSegmentsOneParam = false;
/**
* For Auto Routing (Improved).
* Map of URI segments and namespaces.
*
* The key is the first URI segment. The value is the controller namespace.
* E.g.,
* [
* 'blog' => 'Acme\Blog\Controllers',
* ]
*
* @var array<string, string>
*/
public array $moduleRoutes = [];
/**
* For Auto Routing (Improved).
* Whether to translate dashes in URIs for controller/method to CamelCase.
* E.g., blog-controller -> BlogController
*
* If you enable this, $translateURIDashes is ignored.
*
* Default: false
*/
public bool $translateUriToCamelCase = true;
}

86
app/Config/Security.php Normal file
View File

@ -0,0 +1,86 @@
<?php
namespace Config;
use CodeIgniter\Config\BaseConfig;
class Security extends BaseConfig
{
/**
* --------------------------------------------------------------------------
* CSRF Protection Method
* --------------------------------------------------------------------------
*
* Protection Method for Cross Site Request Forgery protection.
*
* @var string 'cookie' or 'session'
*/
public string $csrfProtection = 'cookie';
/**
* --------------------------------------------------------------------------
* CSRF Token Randomization
* --------------------------------------------------------------------------
*
* Randomize the CSRF Token for added security.
*/
public bool $tokenRandomize = false;
/**
* --------------------------------------------------------------------------
* CSRF Token Name
* --------------------------------------------------------------------------
*
* Token name for Cross Site Request Forgery protection.
*/
public string $tokenName = 'csrf_test_name';
/**
* --------------------------------------------------------------------------
* CSRF Header Name
* --------------------------------------------------------------------------
*
* Header name for Cross Site Request Forgery protection.
*/
public string $headerName = 'X-CSRF-TOKEN';
/**
* --------------------------------------------------------------------------
* CSRF Cookie Name
* --------------------------------------------------------------------------
*
* Cookie name for Cross Site Request Forgery protection.
*/
public string $cookieName = 'csrf_cookie_name';
/**
* --------------------------------------------------------------------------
* CSRF Expires
* --------------------------------------------------------------------------
*
* Expiration time for Cross Site Request Forgery protection cookie.
*
* Defaults to two hours (in seconds).
*/
public int $expires = 7200;
/**
* --------------------------------------------------------------------------
* CSRF Regenerate
* --------------------------------------------------------------------------
*
* Regenerate CSRF Token on every submission.
*/
public bool $regenerate = true;
/**
* --------------------------------------------------------------------------
* CSRF Redirect
* --------------------------------------------------------------------------
*
* Redirect to previous page with error on failure.
*
* @see https://codeigniter4.github.io/userguide/libraries/security.html#redirection-on-failure
*/
public bool $redirect = (ENVIRONMENT === 'production');
}

32
app/Config/Services.php Normal file
View File

@ -0,0 +1,32 @@
<?php
namespace Config;
use CodeIgniter\Config\BaseService;
/**
* Services Configuration file.
*
* Services are simply other classes/libraries that the system uses
* to do its job. This is used by CodeIgniter to allow the core of the
* framework to be swapped out easily without affecting the usage within
* the rest of your application.
*
* This file holds any application-specific services, or service overrides
* that you might need. An example has been included with the general
* method format you should use for your service methods. For more examples,
* see the core Services file at system/Config/Services.php.
*/
class Services extends BaseService
{
/*
* public static function example($getShared = true)
* {
* if ($getShared) {
* return static::getSharedInstance('example');
* }
*
* return new \CodeIgniter\Example();
* }
*/
}

127
app/Config/Session.php Normal file
View File

@ -0,0 +1,127 @@
<?php
namespace Config;
use CodeIgniter\Config\BaseConfig;
use CodeIgniter\Session\Handlers\BaseHandler;
use CodeIgniter\Session\Handlers\FileHandler;
class Session extends BaseConfig
{
/**
* --------------------------------------------------------------------------
* Session Driver
* --------------------------------------------------------------------------
*
* The session storage driver to use:
* - `CodeIgniter\Session\Handlers\FileHandler`
* - `CodeIgniter\Session\Handlers\DatabaseHandler`
* - `CodeIgniter\Session\Handlers\MemcachedHandler`
* - `CodeIgniter\Session\Handlers\RedisHandler`
*
* @var class-string<BaseHandler>
*/
public string $driver = FileHandler::class;
/**
* --------------------------------------------------------------------------
* Session Cookie Name
* --------------------------------------------------------------------------
*
* The session cookie name, must contain only [0-9a-z_-] characters
*/
public string $cookieName = 'ci_session';
/**
* --------------------------------------------------------------------------
* Session Expiration
* --------------------------------------------------------------------------
*
* The number of SECONDS you want the session to last.
* Setting to 0 (zero) means expire when the browser is closed.
*/
public int $expiration = 7200;
/**
* --------------------------------------------------------------------------
* Session Save Path
* --------------------------------------------------------------------------
*
* The location to save sessions to and is driver dependent.
*
* For the 'files' driver, it's a path to a writable directory.
* WARNING: Only absolute paths are supported!
*
* For the 'database' driver, it's a table name.
* Please read up the manual for the format with other session drivers.
*
* IMPORTANT: You are REQUIRED to set a valid save path!
*/
public string $savePath = WRITEPATH . 'session';
/**
* --------------------------------------------------------------------------
* Session Match IP
* --------------------------------------------------------------------------
*
* Whether to match the user's IP address when reading the session data.
*
* WARNING: If you're using the database driver, don't forget to update
* your session table's PRIMARY KEY when changing this setting.
*/
public bool $matchIP = false;
/**
* --------------------------------------------------------------------------
* Session Time to Update
* --------------------------------------------------------------------------
*
* How many seconds between CI regenerating the session ID.
*/
public int $timeToUpdate = 300;
/**
* --------------------------------------------------------------------------
* Session Regenerate Destroy
* --------------------------------------------------------------------------
*
* Whether to destroy session data associated with the old session ID
* when auto-regenerating the session ID. When set to FALSE, the data
* will be later deleted by the garbage collector.
*/
public bool $regenerateDestroy = false;
/**
* --------------------------------------------------------------------------
* Session Database Group
* --------------------------------------------------------------------------
*
* DB Group for the database session.
*/
public ?string $DBGroup = null;
/**
* --------------------------------------------------------------------------
* Lock Retry Interval (microseconds)
* --------------------------------------------------------------------------
*
* This is used for RedisHandler.
*
* Time (microseconds) to wait if lock cannot be acquired.
* The default is 100,000 microseconds (= 0.1 seconds).
*/
public int $lockRetryInterval = 100_000;
/**
* --------------------------------------------------------------------------
* Lock Max Retries
* --------------------------------------------------------------------------
*
* This is used for RedisHandler.
*
* Maximum number of lock acquisition attempts.
* The default is 300 times. That is lock timeout is about 30 (0.1 * 300)
* seconds.
*/
public int $lockMaxRetries = 300;
}

122
app/Config/Toolbar.php Normal file
View File

@ -0,0 +1,122 @@
<?php
namespace Config;
use CodeIgniter\Config\BaseConfig;
use CodeIgniter\Debug\Toolbar\Collectors\Database;
use CodeIgniter\Debug\Toolbar\Collectors\Events;
use CodeIgniter\Debug\Toolbar\Collectors\Files;
use CodeIgniter\Debug\Toolbar\Collectors\Logs;
use CodeIgniter\Debug\Toolbar\Collectors\Routes;
use CodeIgniter\Debug\Toolbar\Collectors\Timers;
use CodeIgniter\Debug\Toolbar\Collectors\Views;
/**
* --------------------------------------------------------------------------
* Debug Toolbar
* --------------------------------------------------------------------------
*
* The Debug Toolbar provides a way to see information about the performance
* and state of your application during that page display. By default it will
* NOT be displayed under production environments, and will only display if
* `CI_DEBUG` is true, since if it's not, there's not much to display anyway.
*/
class Toolbar extends BaseConfig
{
/**
* --------------------------------------------------------------------------
* Toolbar Collectors
* --------------------------------------------------------------------------
*
* List of toolbar collectors that will be called when Debug Toolbar
* fires up and collects data from.
*
* @var list<class-string>
*/
public array $collectors = [
Timers::class,
Database::class,
Logs::class,
Views::class,
// \CodeIgniter\Debug\Toolbar\Collectors\Cache::class,
Files::class,
Routes::class,
Events::class,
];
/**
* --------------------------------------------------------------------------
* Collect Var Data
* --------------------------------------------------------------------------
*
* If set to false var data from the views will not be collected. Useful to
* avoid high memory usage when there are lots of data passed to the view.
*/
public bool $collectVarData = true;
/**
* --------------------------------------------------------------------------
* Max History
* --------------------------------------------------------------------------
*
* `$maxHistory` sets a limit on the number of past requests that are stored,
* helping to conserve file space used to store them. You can set it to
* 0 (zero) to not have any history stored, or -1 for unlimited history.
*/
public int $maxHistory = 20;
/**
* --------------------------------------------------------------------------
* Toolbar Views Path
* --------------------------------------------------------------------------
*
* The full path to the the views that are used by the toolbar.
* This MUST have a trailing slash.
*/
public string $viewsPath = SYSTEMPATH . 'Debug/Toolbar/Views/';
/**
* --------------------------------------------------------------------------
* Max Queries
* --------------------------------------------------------------------------
*
* If the Database Collector is enabled, it will log every query that the
* the system generates so they can be displayed on the toolbar's timeline
* and in the query log. This can lead to memory issues in some instances
* with hundreds of queries.
*
* `$maxQueries` defines the maximum amount of queries that will be stored.
*/
public int $maxQueries = 100;
/**
* --------------------------------------------------------------------------
* Watched Directories
* --------------------------------------------------------------------------
*
* Contains an array of directories that will be watched for changes and
* used to determine if the hot-reload feature should reload the page or not.
* We restrict the values to keep performance as high as possible.
*
* NOTE: The ROOTPATH will be prepended to all values.
*
* @var list<string>
*/
public array $watchedDirectories = [
'app',
];
/**
* --------------------------------------------------------------------------
* Watched File Extensions
* --------------------------------------------------------------------------
*
* Contains an array of file extensions that will be watched for changes and
* used to determine if the hot-reload feature should reload the page or not.
*
* @var list<string>
*/
public array $watchedExtensions = [
'php', 'css', 'js', 'html', 'svg', 'json', 'env',
];
}

252
app/Config/UserAgents.php Normal file
View File

@ -0,0 +1,252 @@
<?php
namespace Config;
use CodeIgniter\Config\BaseConfig;
/**
* -------------------------------------------------------------------
* User Agents
* -------------------------------------------------------------------
*
* This file contains four arrays of user agent data. It is used by the
* User Agent Class to help identify browser, platform, robot, and
* mobile device data. The array keys are used to identify the device
* and the array values are used to set the actual name of the item.
*/
class UserAgents extends BaseConfig
{
/**
* -------------------------------------------------------------------
* OS Platforms
* -------------------------------------------------------------------
*
* @var array<string, string>
*/
public array $platforms = [
'windows nt 10.0' => 'Windows 10',
'windows nt 6.3' => 'Windows 8.1',
'windows nt 6.2' => 'Windows 8',
'windows nt 6.1' => 'Windows 7',
'windows nt 6.0' => 'Windows Vista',
'windows nt 5.2' => 'Windows 2003',
'windows nt 5.1' => 'Windows XP',
'windows nt 5.0' => 'Windows 2000',
'windows nt 4.0' => 'Windows NT 4.0',
'winnt4.0' => 'Windows NT 4.0',
'winnt 4.0' => 'Windows NT',
'winnt' => 'Windows NT',
'windows 98' => 'Windows 98',
'win98' => 'Windows 98',
'windows 95' => 'Windows 95',
'win95' => 'Windows 95',
'windows phone' => 'Windows Phone',
'windows' => 'Unknown Windows OS',
'android' => 'Android',
'blackberry' => 'BlackBerry',
'iphone' => 'iOS',
'ipad' => 'iOS',
'ipod' => 'iOS',
'os x' => 'Mac OS X',
'ppc mac' => 'Power PC Mac',
'freebsd' => 'FreeBSD',
'ppc' => 'Macintosh',
'linux' => 'Linux',
'debian' => 'Debian',
'sunos' => 'Sun Solaris',
'beos' => 'BeOS',
'apachebench' => 'ApacheBench',
'aix' => 'AIX',
'irix' => 'Irix',
'osf' => 'DEC OSF',
'hp-ux' => 'HP-UX',
'netbsd' => 'NetBSD',
'bsdi' => 'BSDi',
'openbsd' => 'OpenBSD',
'gnu' => 'GNU/Linux',
'unix' => 'Unknown Unix OS',
'symbian' => 'Symbian OS',
];
/**
* -------------------------------------------------------------------
* Browsers
* -------------------------------------------------------------------
*
* The order of this array should NOT be changed. Many browsers return
* multiple browser types so we want to identify the subtype first.
*
* @var array<string, string>
*/
public array $browsers = [
'OPR' => 'Opera',
'Flock' => 'Flock',
'Edge' => 'Spartan',
'Edg' => 'Edge',
'Chrome' => 'Chrome',
// Opera 10+ always reports Opera/9.80 and appends Version/<real version> to the user agent string
'Opera.*?Version' => 'Opera',
'Opera' => 'Opera',
'MSIE' => 'Internet Explorer',
'Internet Explorer' => 'Internet Explorer',
'Trident.* rv' => 'Internet Explorer',
'Shiira' => 'Shiira',
'Firefox' => 'Firefox',
'Chimera' => 'Chimera',
'Phoenix' => 'Phoenix',
'Firebird' => 'Firebird',
'Camino' => 'Camino',
'Netscape' => 'Netscape',
'OmniWeb' => 'OmniWeb',
'Safari' => 'Safari',
'Mozilla' => 'Mozilla',
'Konqueror' => 'Konqueror',
'icab' => 'iCab',
'Lynx' => 'Lynx',
'Links' => 'Links',
'hotjava' => 'HotJava',
'amaya' => 'Amaya',
'IBrowse' => 'IBrowse',
'Maxthon' => 'Maxthon',
'Ubuntu' => 'Ubuntu Web Browser',
'Vivaldi' => 'Vivaldi',
];
/**
* -------------------------------------------------------------------
* Mobiles
* -------------------------------------------------------------------
*
* @var array<string, string>
*/
public array $mobiles = [
// legacy array, old values commented out
'mobileexplorer' => 'Mobile Explorer',
// 'openwave' => 'Open Wave',
// 'opera mini' => 'Opera Mini',
// 'operamini' => 'Opera Mini',
// 'elaine' => 'Palm',
'palmsource' => 'Palm',
// 'digital paths' => 'Palm',
// 'avantgo' => 'Avantgo',
// 'xiino' => 'Xiino',
'palmscape' => 'Palmscape',
// 'nokia' => 'Nokia',
// 'ericsson' => 'Ericsson',
// 'blackberry' => 'BlackBerry',
// 'motorola' => 'Motorola'
// Phones and Manufacturers
'motorola' => 'Motorola',
'nokia' => 'Nokia',
'palm' => 'Palm',
'iphone' => 'Apple iPhone',
'ipad' => 'iPad',
'ipod' => 'Apple iPod Touch',
'sony' => 'Sony Ericsson',
'ericsson' => 'Sony Ericsson',
'blackberry' => 'BlackBerry',
'cocoon' => 'O2 Cocoon',
'blazer' => 'Treo',
'lg' => 'LG',
'amoi' => 'Amoi',
'xda' => 'XDA',
'mda' => 'MDA',
'vario' => 'Vario',
'htc' => 'HTC',
'samsung' => 'Samsung',
'sharp' => 'Sharp',
'sie-' => 'Siemens',
'alcatel' => 'Alcatel',
'benq' => 'BenQ',
'ipaq' => 'HP iPaq',
'mot-' => 'Motorola',
'playstation portable' => 'PlayStation Portable',
'playstation 3' => 'PlayStation 3',
'playstation vita' => 'PlayStation Vita',
'hiptop' => 'Danger Hiptop',
'nec-' => 'NEC',
'panasonic' => 'Panasonic',
'philips' => 'Philips',
'sagem' => 'Sagem',
'sanyo' => 'Sanyo',
'spv' => 'SPV',
'zte' => 'ZTE',
'sendo' => 'Sendo',
'nintendo dsi' => 'Nintendo DSi',
'nintendo ds' => 'Nintendo DS',
'nintendo 3ds' => 'Nintendo 3DS',
'wii' => 'Nintendo Wii',
'open web' => 'Open Web',
'openweb' => 'OpenWeb',
// Operating Systems
'android' => 'Android',
'symbian' => 'Symbian',
'SymbianOS' => 'SymbianOS',
'elaine' => 'Palm',
'series60' => 'Symbian S60',
'windows ce' => 'Windows CE',
// Browsers
'obigo' => 'Obigo',
'netfront' => 'Netfront Browser',
'openwave' => 'Openwave Browser',
'mobilexplorer' => 'Mobile Explorer',
'operamini' => 'Opera Mini',
'opera mini' => 'Opera Mini',
'opera mobi' => 'Opera Mobile',
'fennec' => 'Firefox Mobile',
// Other
'digital paths' => 'Digital Paths',
'avantgo' => 'AvantGo',
'xiino' => 'Xiino',
'novarra' => 'Novarra Transcoder',
'vodafone' => 'Vodafone',
'docomo' => 'NTT DoCoMo',
'o2' => 'O2',
// Fallback
'mobile' => 'Generic Mobile',
'wireless' => 'Generic Mobile',
'j2me' => 'Generic Mobile',
'midp' => 'Generic Mobile',
'cldc' => 'Generic Mobile',
'up.link' => 'Generic Mobile',
'up.browser' => 'Generic Mobile',
'smartphone' => 'Generic Mobile',
'cellphone' => 'Generic Mobile',
];
/**
* -------------------------------------------------------------------
* Robots
* -------------------------------------------------------------------
*
* There are hundred of bots but these are the most common.
*
* @var array<string, string>
*/
public array $robots = [
'googlebot' => 'Googlebot',
'msnbot' => 'MSNBot',
'baiduspider' => 'Baiduspider',
'bingbot' => 'Bing',
'slurp' => 'Inktomi Slurp',
'yahoo' => 'Yahoo',
'ask jeeves' => 'Ask Jeeves',
'fastcrawler' => 'FastCrawler',
'infoseek' => 'InfoSeek Robot 1.0',
'lycos' => 'Lycos',
'yandex' => 'YandexBot',
'mediapartners-google' => 'MediaPartners Google',
'CRAZYWEBCRAWLER' => 'Crazy Webcrawler',
'adsbot-google' => 'AdsBot Google',
'feedfetcher-google' => 'Feedfetcher Google',
'curious george' => 'Curious George',
'ia_archiver' => 'Alexa Crawler',
'MJ12bot' => 'Majestic-12',
'Uptimebot' => 'Uptimebot',
];
}

44
app/Config/Validation.php Normal file
View File

@ -0,0 +1,44 @@
<?php
namespace Config;
use CodeIgniter\Config\BaseConfig;
use CodeIgniter\Validation\StrictRules\CreditCardRules;
use CodeIgniter\Validation\StrictRules\FileRules;
use CodeIgniter\Validation\StrictRules\FormatRules;
use CodeIgniter\Validation\StrictRules\Rules;
class Validation extends BaseConfig
{
// --------------------------------------------------------------------
// Setup
// --------------------------------------------------------------------
/**
* Stores the classes that contain the
* rules that are available.
*
* @var list<string>
*/
public array $ruleSets = [
Rules::class,
FormatRules::class,
FileRules::class,
CreditCardRules::class,
];
/**
* Specifies the views that are used to display the
* errors.
*
* @var array<string, string>
*/
public array $templates = [
'list' => 'CodeIgniter\Validation\Views\list',
'single' => 'CodeIgniter\Validation\Views\single',
];
// --------------------------------------------------------------------
// Rules
// --------------------------------------------------------------------
}

62
app/Config/View.php Normal file
View File

@ -0,0 +1,62 @@
<?php
namespace Config;
use CodeIgniter\Config\View as BaseView;
use CodeIgniter\View\ViewDecoratorInterface;
/**
* @phpstan-type parser_callable (callable(mixed): mixed)
* @phpstan-type parser_callable_string (callable(mixed): mixed)&string
*/
class View extends BaseView
{
/**
* When false, the view method will clear the data between each
* call. This keeps your data safe and ensures there is no accidental
* leaking between calls, so you would need to explicitly pass the data
* to each view. You might prefer to have the data stick around between
* calls so that it is available to all views. If that is the case,
* set $saveData to true.
*
* @var bool
*/
public $saveData = true;
/**
* Parser Filters map a filter name with any PHP callable. When the
* Parser prepares a variable for display, it will chain it
* through the filters in the order defined, inserting any parameters.
* To prevent potential abuse, all filters MUST be defined here
* in order for them to be available for use within the Parser.
*
* Examples:
* { title|esc(js) }
* { created_on|date(Y-m-d)|esc(attr) }
*
* @var array<string, string>
* @phpstan-var array<string, parser_callable_string>
*/
public $filters = [];
/**
* Parser Plugins provide a way to extend the functionality provided
* by the core Parser by creating aliases that will be replaced with
* any callable. Can be single or tag pair.
*
* @var array<string, callable|list<string>|string>
* @phpstan-var array<string, list<parser_callable_string>|parser_callable_string|parser_callable>
*/
public $plugins = [];
/**
* View Decorators are class methods that will be run in sequence to
* have a chance to alter the generated output just prior to caching
* the results.
*
* All classes must implement CodeIgniter\View\ViewDecoratorInterface
*
* @var list<class-string<ViewDecoratorInterface>>
*/
public array $decorators = [];
}

View File

@ -0,0 +1,151 @@
<?php
namespace App\Controllers\Api;
use App\Controllers\BaseController;
use App\Models\DictControlModel;
use App\Models\ControlTestModel;
class ControlApiController extends BaseController
{
protected $dictControlModel;
protected $controlTestModel;
public function __construct()
{
$this->dictControlModel = new DictControlModel();
$this->controlTestModel = new ControlTestModel();
}
public function index()
{
$controls = $this->dictControlModel->getWithDept();
return $this->response->setJSON([
'status' => 'success',
'message' => 'Controls fetched successfully',
'data' => $controls
]);
}
public function show($id)
{
$control = $this->dictControlModel->find($id);
if (!$control) {
return $this->response->setJSON([
'status' => 'error',
'message' => 'Control not found'
])->setStatusCode(404);
}
return $this->response->setJSON([
'status' => 'success',
'data' => $control
]);
}
public function getTests($id)
{
$tests = $this->controlTestModel->where('control_ref_id', $id)->findAll();
$testIds = array_column($tests, 'test_ref_id');
return $this->response->setJSON([
'status' => 'success',
'data' => $testIds
]);
}
public function store()
{
$post = $this->request->getJSON(true);
$controlData = [
'dept_ref_id' => $post['dept_ref_id'] ?? null,
'name' => $post['name'] ?? '',
'lot' => $post['lot'] ?? '',
'producer' => $post['producer'] ?? '',
'expdate' => $post['expdate'] ?? null,
];
$controlId = $this->dictControlModel->insert($controlData, true);
if (!empty($post['test_ids'])) {
foreach ($post['test_ids'] as $testId) {
$this->controlTestModel->insert([
'control_ref_id' => $controlId,
'test_ref_id' => $testId,
'mean' => 0,
'sd' => 0,
]);
}
}
if ($controlId) {
return $this->response->setJSON([
'status' => 'success',
'message' => 'Control saved successfully',
'data' => ['control_id' => $controlId]
]);
}
return $this->response->setJSON([
'status' => 'error',
'message' => 'Failed to save control'
])->setStatusCode(500);
}
public function update($id)
{
$post = $this->request->getJSON(true);
$controlData = [
'dept_ref_id' => $post['dept_ref_id'] ?? null,
'name' => $post['name'] ?? '',
'lot' => $post['lot'] ?? '',
'producer' => $post['producer'] ?? '',
'expdate' => $post['expdate'] ?? null,
];
$success = $this->dictControlModel->update($id, $controlData);
if (!empty($post['test_ids'])) {
$this->controlTestModel->where('control_ref_id', $id)->delete();
foreach ($post['test_ids'] as $testId) {
$this->controlTestModel->insert([
'control_ref_id' => $id,
'test_ref_id' => $testId,
'mean' => 0,
'sd' => 0,
]);
}
}
if ($success) {
return $this->response->setJSON([
'status' => 'success',
'message' => 'Control updated successfully'
]);
}
return $this->response->setJSON([
'status' => 'error',
'message' => 'Failed to update control'
])->setStatusCode(500);
}
public function delete($id)
{
$this->controlTestModel->where('control_ref_id', $id)->delete();
$success = $this->dictControlModel->delete($id);
if ($success) {
return $this->response->setJSON([
'status' => 'success',
'message' => 'Control deleted successfully'
]);
}
return $this->response->setJSON([
'status' => 'error',
'message' => 'Failed to delete control'
])->setStatusCode(500);
}
}

View File

@ -0,0 +1,105 @@
<?php
namespace App\Controllers\Api;
use App\Controllers\BaseController;
use App\Models\DictDeptModel;
class DeptApiController extends BaseController
{
protected $dictDeptModel;
public function __construct()
{
$this->dictDeptModel = new DictDeptModel();
}
public function index()
{
$depts = $this->dictDeptModel->findAll();
return $this->response->setJSON([
'status' => 'success',
'message' => 'Departments fetched successfully',
'data' => $depts
]);
}
public function show($id)
{
$dept = $this->dictDeptModel->find($id);
if (!$dept) {
return $this->response->setJSON([
'status' => 'error',
'message' => 'Department not found'
])->setStatusCode(404);
}
return $this->response->setJSON([
'status' => 'success',
'data' => $dept
]);
}
public function store()
{
$post = $this->request->getJSON(true);
$data = [
'name' => $post['name'] ?? '',
];
$id = $this->dictDeptModel->insert($data);
if ($id) {
return $this->response->setJSON([
'status' => 'success',
'message' => 'Department saved successfully',
'data' => ['dept_id' => $id]
]);
}
return $this->response->setJSON([
'status' => 'error',
'message' => 'Failed to save department'
])->setStatusCode(500);
}
public function update($id)
{
$post = $this->request->getJSON(true);
$data = [
'name' => $post['name'] ?? '',
];
$success = $this->dictDeptModel->update($id, $data);
if ($success) {
return $this->response->setJSON([
'status' => 'success',
'message' => 'Department updated successfully'
]);
}
return $this->response->setJSON([
'status' => 'error',
'message' => 'Failed to update department'
])->setStatusCode(500);
}
public function delete($id)
{
$success = $this->dictDeptModel->delete($id);
if ($success) {
return $this->response->setJSON([
'status' => 'success',
'message' => 'Department deleted successfully'
]);
}
return $this->response->setJSON([
'status' => 'error',
'message' => 'Failed to delete department'
])->setStatusCode(500);
}
}

View File

@ -0,0 +1,143 @@
<?php
namespace App\Controllers\Api;
use App\Controllers\BaseController;
use App\Models\DictControlModel;
use App\Models\ControlTestModel;
use App\Models\ResultModel;
use App\Models\ResultCommentModel;
class EntryApiController extends BaseController
{
protected $dictControlModel;
protected $controlTestModel;
protected $resultModel;
protected $commentModel;
public function __construct()
{
$this->dictControlModel = new \App\Models\DictControlModel();
$this->controlTestModel = new \App\Models\ControlTestModel();
$this->resultModel = new \App\Models\ResultModel();
$this->commentModel = new \App\Models\ResultCommentModel();
}
public function getControls()
{
$date = $this->request->getGet('date');
$deptid = $this->request->getGet('deptid');
$controls = $this->dictControlModel->getActiveByDate($date, $deptid);
return $this->response->setJSON([
'status' => 'success',
'message' => 'Controls fetched successfully',
'data' => $controls
]);
}
public function getTests()
{
$controlid = $this->request->getGet('controlid');
$tests = $this->controlTestModel->getByControl($controlid);
return $this->response->setJSON([
'status' => 'success',
'message' => 'Tests fetched successfully',
'data' => $tests
]);
}
public function saveDaily()
{
$post = $this->request->getPost();
$resultData = [
'control_ref_id' => $post['controlid'] ?? 0,
'test_ref_id' => $post['testid'] ?? 0,
'resdate' => $post['resdate'] ?? date('Y-m-d'),
'resvalue' => $post['resvalue'] ?? '',
'rescomment' => $post['rescomment'] ?? '',
];
$success = $this->resultModel->saveResult($resultData);
if ($success) {
return $this->response->setJSON([
'status' => 'success',
'message' => 'Result saved successfully'
]);
}
return $this->response->setJSON([
'status' => 'error',
'message' => 'Failed to save result'
])->setStatusCode(500);
}
public function saveMonthly()
{
$post = $this->request->getPost();
$controlid = $post['controlid'] ?? 0;
$testid = $post['testid'] ?? 0;
$dates = $post['dates'] ?? '';
$resvalues = $post['resvalue'] ?? [];
$success = true;
foreach ($resvalues as $day => $value) {
if (!empty($value)) {
$resultData = [
'control_ref_id' => $controlid,
'test_ref_id' => $testid,
'resdate' => $dates . '-' . str_pad($day, 2, '0', STR_PAD_LEFT),
'resvalue' => $value,
'rescomment' => '',
];
if (!$this->resultModel->saveResult($resultData)) {
$success = false;
}
}
}
if ($success) {
return $this->response->setJSON([
'status' => 'success',
'message' => 'Monthly data saved successfully'
]);
}
return $this->response->setJSON([
'status' => 'error',
'message' => 'Failed to save some entries'
])->setStatusCode(500);
}
public function saveComment()
{
$post = $this->request->getPost();
$commentData = [
'control_ref_id' => $post['controlid'] ?? 0,
'test_ref_id' => $post['testid'] ?? 0,
'commonth' => $post['commonth'] ?? '',
'comtext' => $post['comtext'] ?? '',
];
$success = $this->commentModel->saveComment($commentData);
if ($success) {
return $this->response->setJSON([
'status' => 'success',
'message' => 'Comment saved successfully'
]);
}
return $this->response->setJSON([
'status' => 'error',
'message' => 'Failed to save comment'
])->setStatusCode(500);
}
}

View File

@ -0,0 +1,120 @@
<?php
namespace App\Controllers\Api;
use App\Controllers\BaseController;
use App\Models\DictTestModel;
use App\Models\DictDeptModel;
class TestApiController extends BaseController
{
protected $dictTestModel;
protected $dictDeptModel;
public function __construct()
{
$this->dictTestModel = new DictTestModel();
$this->dictDeptModel = new DictDeptModel();
}
public function index()
{
$tests = $this->dictTestModel->getWithDept();
return $this->response->setJSON([
'status' => 'success',
'message' => 'Tests fetched successfully',
'data' => $tests
]);
}
public function show($id)
{
$test = $this->dictTestModel->find($id);
if (!$test) {
return $this->response->setJSON([
'status' => 'error',
'message' => 'Test not found'
])->setStatusCode(404);
}
return $this->response->setJSON([
'status' => 'success',
'data' => $test
]);
}
public function store()
{
$post = $this->request->getJSON(true);
$testData = [
'dept_ref_id' => $post['dept_ref_id'] ?? null,
'name' => $post['name'] ?? '',
'unit' => $post['unit'] ?? '',
'method' => $post['method'] ?? '',
'cva' => $post['cva'] ?? '',
'ba' => $post['ba'] ?? '',
'tea' => $post['tea'] ?? '',
];
$id = $this->dictTestModel->insert($testData);
if ($id) {
return $this->response->setJSON([
'status' => 'success',
'message' => 'Test saved successfully',
'data' => ['test_id' => $id]
]);
}
return $this->response->setJSON([
'status' => 'error',
'message' => 'Failed to save test'
])->setStatusCode(500);
}
public function update($id)
{
$post = $this->request->getJSON(true);
$testData = [
'dept_ref_id' => $post['dept_ref_id'] ?? null,
'name' => $post['name'] ?? '',
'unit' => $post['unit'] ?? '',
'method' => $post['method'] ?? '',
'cva' => $post['cva'] ?? '',
'ba' => $post['ba'] ?? '',
'tea' => $post['tea'] ?? '',
];
$success = $this->dictTestModel->update($id, $testData);
if ($success) {
return $this->response->setJSON([
'status' => 'success',
'message' => 'Test updated successfully'
]);
}
return $this->response->setJSON([
'status' => 'error',
'message' => 'Failed to update test'
])->setStatusCode(500);
}
public function delete($id)
{
$success = $this->dictTestModel->delete($id);
if ($success) {
return $this->response->setJSON([
'status' => 'success',
'message' => 'Test deleted successfully'
]);
}
return $this->response->setJSON([
'status' => 'error',
'message' => 'Failed to delete test'
])->setStatusCode(500);
}
}

View File

@ -0,0 +1,20 @@
<?php
namespace App\Controllers;
use CodeIgniter\Controller;
use CodeIgniter\HTTP\RequestInterface;
use CodeIgniter\HTTP\ResponseInterface;
use Psr\Log\LoggerInterface;
abstract class BaseController extends Controller
{
protected $session;
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
{
parent::initController($request, $response, $logger);
$this->session = \Config\Services::session();
$this->helpers = ['form', 'url'];
}
}

View File

@ -0,0 +1,36 @@
<?php
namespace App\Controllers;
use App\Models\DictControlModel;
use App\Models\ControlTestModel;
use App\Models\DictDeptModel;
use App\Models\DictTestModel;
class Control extends BaseController
{
protected $dictControlModel;
protected $controlTestModel;
protected $dictDeptModel;
protected $dictTestModel;
public function __construct()
{
$this->dictControlModel = new DictControlModel();
$this->controlTestModel = new ControlTestModel();
$this->dictDeptModel = new DictDeptModel();
$this->dictTestModel = new DictTestModel();
}
public function index(): string
{
return view('control/index', [
'title' => 'Control Dictionary',
'controls' => $this->dictControlModel->getWithDept(),
'depts' => $this->dictDeptModel->findAll(),
'tests' => $this->dictTestModel->getWithDept(),
'active_menu' => 'control',
'page_title' => 'Control Dictionary'
]);
}
}

View File

@ -0,0 +1,28 @@
<?php
namespace App\Controllers;
use App\Models\DictDeptModel;
use App\Models\DictTestModel;
use App\Models\DictControlModel;
use App\Models\ResultModel;
class Dashboard extends BaseController
{
public function index()
{
$dictDeptModel = new DictDeptModel();
$dictTestModel = new DictTestModel();
$dictControlModel = new DictControlModel();
$resultModel = new ResultModel();
return view('dashboard', [
'depts' => $dictDeptModel->findAll(),
'tests' => $dictTestModel->getWithDept(),
'controls' => $dictControlModel->getWithDept(),
'recent_results' => $resultModel->findAll(20),
'page_title' => 'Dashboard',
'active_menu' => 'dashboard'
]);
}
}

25
app/Controllers/Dept.php Normal file
View File

@ -0,0 +1,25 @@
<?php
namespace App\Controllers;
use App\Models\DictDeptModel;
class Dept extends BaseController
{
protected $dictDeptModel;
public function __construct()
{
$this->dictDeptModel = new DictDeptModel();
}
public function index(): string
{
return view('dept/index', [
'title' => 'Department Dictionary',
'depts' => $this->dictDeptModel->findAll(),
'active_menu' => 'dept',
'page_title' => 'Department Dictionary'
]);
}
}

32
app/Controllers/Entry.php Normal file
View File

@ -0,0 +1,32 @@
<?php
namespace App\Controllers;
use App\Models\DictDeptModel;
class Entry extends BaseController
{
public function index()
{
$dictDeptModel = new \App\Models\DictDeptModel();
return view('entry/monthly', [
'title' => 'Monthly Entry',
'depts' => $dictDeptModel->findAll(),
'active_menu' => 'entry',
'page_title' => 'Monthly Entry'
]);
}
public function daily()
{
$dictDeptModel = new \App\Models\DictDeptModel();
return view('entry/daily', [
'title' => 'Daily Entry',
'depts' => $dictDeptModel->findAll(),
'active_menu' => 'entry_daily',
'page_title' => 'Daily Entry'
]);
}
}

View File

@ -0,0 +1,158 @@
<?php
namespace App\Controllers;
class PageController extends BaseController
{
protected $dictDeptModel;
protected $dictTestModel;
protected $dictControlModel;
protected $resultModel;
protected $controlTestModel;
protected $commentModel;
public function __construct()
{
$this->dictDeptModel = new \App\Models\DictDeptModel();
$this->dictTestModel = new \App\Models\DictTestModel();
$this->dictControlModel = new \App\Models\DictControlModel();
$this->resultModel = new \App\Models\ResultModel();
$this->controlTestModel = new \App\Models\ControlTestModel();
$this->commentModel = new \App\Models\ResultCommentModel();
}
public function dashboard(): string
{
return view('dashboard', [
'depts' => $this->dictDeptModel->findAll(),
'tests' => $this->dictTestModel->getWithDept(),
'controls' => $this->dictControlModel->getWithDept(),
'recent_results' => $this->resultModel->findAll(20),
'page_title' => 'Dashboard',
'active_menu' => 'dashboard'
]);
}
public function dept(): string
{
return view('dept/index', [
'title' => 'Department Dictionary',
'depts' => $this->dictDeptModel->findAll(),
'active_menu' => 'dept',
'page_title' => 'Department Dictionary'
]);
}
public function test(): string
{
return view('test/index', [
'title' => 'Test Dictionary',
'tests' => $this->dictTestModel->getWithDept(),
'depts' => $this->dictDeptModel->findAll(),
'active_menu' => 'test',
'page_title' => 'Test Dictionary'
]);
}
public function control(): string
{
return view('control/index', [
'title' => 'Control Dictionary',
'controls' => $this->dictControlModel->getWithDept(),
'depts' => $this->dictDeptModel->findAll(),
'tests' => $this->dictTestModel->getWithDept(),
'active_menu' => 'control',
'page_title' => 'Control Dictionary'
]);
}
public function entry(): string
{
return view('entry/monthly', [
'title' => 'Monthly Entry',
'depts' => $this->dictDeptModel->findAll(),
'active_menu' => 'entry',
'page_title' => 'Monthly Entry'
]);
}
public function entryDaily(): string
{
return view('entry/daily', [
'title' => 'Daily Entry',
'depts' => $this->dictDeptModel->findAll(),
'active_menu' => 'entry_daily',
'page_title' => 'Daily Entry'
]);
}
public function report(): string
{
return view('report/index', [
'title' => 'Reports',
'depts' => $this->dictDeptModel->findAll(),
'tests' => $this->dictTestModel->findAll(),
'controls' => $this->dictControlModel->findAll(),
'active_menu' => 'report',
'page_title' => 'Reports'
]);
}
public function reportView(): string
{
$control1 = $this->request->getGet('control1') ?? 0;
$control2 = $this->request->getGet('control2') ?? 0;
$control3 = $this->request->getGet('control3') ?? 0;
$dates = $this->request->getGet('dates') ?? date('Y-m');
$test = $this->request->getGet('test') ?? 0;
$controls = [];
if ($control1) {
$c1 = $this->dictControlModel->find($control1);
if ($c1) $controls[] = $c1;
}
if ($control2) {
$c2 = $this->dictControlModel->find($control2);
if ($c2) $controls[] = $c2;
}
if ($control3) {
$c3 = $this->dictControlModel->find($control3);
if ($c3) $controls[] = $c3;
}
$reportData = [];
foreach ($controls as $control) {
$controlTest = $this->controlTestModel->getByControlAndTest($control['control_id'], $test);
$results = $this->resultModel->getByMonth($control['control_id'], $test, $dates);
$comment = $this->commentModel->getByControlTestMonth($control['control_id'], $test, $dates);
$outOfRangeCount = 0;
if ($controlTest && $controlTest['sd'] > 0) {
foreach ($results as $res) {
if (abs($res['resvalue'] - $controlTest['mean']) > 2 * $controlTest['sd']) {
$outOfRangeCount++;
}
}
}
$reportData[] = [
'control' => $control,
'controlTest' => $controlTest,
'results' => $results,
'comment' => $comment,
'test' => $this->dictTestModel->find($test),
'outOfRange' => $outOfRangeCount
];
}
return view('report/view', [
'title' => 'QC Report',
'reportData' => $reportData,
'dates' => $dates,
'test' => $test,
'depts' => $this->dictDeptModel->findAll(),
'active_menu' => 'report',
'page_title' => 'QC Report'
]);
}
}

View File

@ -0,0 +1,26 @@
<?php
namespace App\Controllers;
use App\Models\DictDeptModel;
use App\Models\DictTestModel;
use App\Models\DictControlModel;
class Report extends BaseController
{
public function index()
{
$dictDeptModel = new DictDeptModel();
$dictTestModel = new DictTestModel();
$dictControlModel = new DictControlModel();
return view('report/index', [
'title' => 'Reports',
'depts' => $dictDeptModel->findAll(),
'tests' => $dictTestModel->findAll(),
'controls' => $dictControlModel->findAll(),
'active_menu' => 'report',
'page_title' => 'Reports'
]);
}
}

29
app/Controllers/Test.php Normal file
View File

@ -0,0 +1,29 @@
<?php
namespace App\Controllers;
use App\Models\DictTestModel;
use App\Models\DictDeptModel;
class Test extends BaseController
{
protected $dictTestModel;
protected $dictDeptModel;
public function __construct()
{
$this->dictTestModel = new DictTestModel();
$this->dictDeptModel = new DictDeptModel();
}
public function index()
{
return view('test/index', [
'title' => 'Test Dictionary',
'tests' => $this->dictTestModel->getWithDept(),
'depts' => $this->dictDeptModel->findAll(),
'active_menu' => 'test',
'page_title' => 'Test Dictionary'
]);
}
}

View File

View File

@ -0,0 +1,210 @@
<?php
namespace App\Database\Migrations;
use CodeIgniter\Database\Migration;
class CreateCmodQcTables extends Migration
{
public function up()
{
$this->forge->addField([
'control_test_id' => [
'type' => 'INT',
'constraint' => 11,
'unsigned' => true,
'auto_increment' => true,
],
'control_ref_id' => [
'type' => 'INT',
'constraint' => 11,
'null' => true,
],
'test_ref_id' => [
'type' => 'INT',
'constraint' => 11,
'null' => true,
],
'mean' => [
'type' => 'FLOAT',
'null' => true,
],
'sd' => [
'type' => 'FLOAT',
'null' => true,
],
]);
$this->forge->addKey('control_test_id', true);
$this->forge->createTable('control_tests');
$this->forge->addField([
'result_id' => [
'type' => 'INT',
'constraint' => 11,
'unsigned' => true,
'auto_increment' => true,
],
'control_ref_id' => [
'type' => 'INT',
'constraint' => 11,
'null' => true,
],
'test_ref_id' => [
'type' => 'INT',
'constraint' => 11,
'null' => true,
],
'resdate' => [
'type' => 'DATETIME',
'null' => true,
],
'resvalue' => [
'type' => 'VARCHAR',
'constraint' => 50,
'null' => true,
],
'rescomment' => [
'type' => 'TEXT',
'null' => true,
],
]);
$this->forge->addKey('result_id', true);
$this->forge->createTable('results');
$this->forge->addField([
'control_id' => [
'type' => 'INT',
'constraint' => 11,
'unsigned' => true,
'auto_increment' => true,
],
'dept_ref_id' => [
'type' => 'INT',
'constraint' => 11,
'null' => true,
],
'name' => [
'type' => 'VARCHAR',
'constraint' => 50,
'null' => true,
],
'lot' => [
'type' => 'VARCHAR',
'constraint' => 50,
'null' => true,
],
'producer' => [
'type' => 'TEXT',
'null' => true,
],
'expdate' => [
'type' => 'DATE',
'null' => true,
],
]);
$this->forge->addKey('control_id', true);
$this->forge->createTable('dict_controls');
$this->forge->addField([
'dept_id' => [
'type' => 'INT',
'constraint' => 11,
'unsigned' => true,
'auto_increment' => true,
],
'name' => [
'type' => 'VARCHAR',
'constraint' => 50,
'null' => true,
],
]);
$this->forge->addKey('dept_id', true);
$this->forge->createTable('dict_depts');
$this->forge->addField([
'test_id' => [
'type' => 'INT',
'constraint' => 11,
'unsigned' => true,
'auto_increment' => true,
],
'dept_ref_id' => [
'type' => 'INT',
'constraint' => 11,
'null' => true,
],
'name' => [
'type' => 'VARCHAR',
'constraint' => 50,
'null' => true,
],
'unit' => [
'type' => 'VARCHAR',
'constraint' => 50,
'null' => true,
],
'method' => [
'type' => 'VARCHAR',
'constraint' => 50,
'null' => true,
],
'cva' => [
'type' => 'VARCHAR',
'constraint' => 50,
'null' => true,
],
'ba' => [
'type' => 'VARCHAR',
'constraint' => 50,
'null' => true,
],
'tea' => [
'type' => 'VARCHAR',
'constraint' => 50,
'null' => true,
],
]);
$this->forge->addKey('test_id', true);
$this->forge->createTable('dict_tests');
$this->forge->addField([
'result_comment_id' => [
'type' => 'INT',
'constraint' => 11,
'unsigned' => true,
'auto_increment' => true,
],
'control_ref_id' => [
'type' => 'INT',
'constraint' => 11,
'null' => true,
],
'test_ref_id' => [
'type' => 'INT',
'constraint' => 11,
'null' => true,
],
'commonth' => [
'type' => 'VARCHAR',
'constraint' => 7,
'null' => true,
],
'comtext' => [
'type' => 'TEXT',
'null' => true,
],
]);
$this->forge->addKey('result_comment_id', true);
$this->forge->createTable('result_comments');
}
public function down()
{
$this->forge->dropTable('control_tests');
$this->forge->dropTable('results');
$this->forge->dropTable('dict_controls');
$this->forge->dropTable('dict_depts');
$this->forge->dropTable('dict_tests');
$this->forge->dropTable('result_comments');
}
}

View File

View File

@ -0,0 +1,322 @@
<?php
namespace App\Database\Seeds;
use CodeIgniter\Database\Seeder;
class CmodQcSeeder extends Seeder
{
public function run()
{
$data = [
['control_test_id' => 440, 'control_ref_id' => 125, 'test_ref_id' => 18, 'mean' => 1.28, 'sd' => 0.64],
['control_test_id' => 441, 'control_ref_id' => 126, 'test_ref_id' => 18, 'mean' => 2.26, 'sd' => 1.13],
['control_test_id' => 541, 'control_ref_id' => 169, 'test_ref_id' => 18, 'mean' => 1.24, 'sd' => 0.155],
['control_test_id' => 443, 'control_ref_id' => 128, 'test_ref_id' => 20, 'mean' => 105, 'sd' => 14.6],
['control_test_id' => 565, 'control_ref_id' => 179, 'test_ref_id' => 15, 'mean' => 44, 'sd' => 2.2],
['control_test_id' => 566, 'control_ref_id' => 179, 'test_ref_id' => 16, 'mean' => 107, 'sd' => 5.35],
['control_test_id' => 482, 'control_ref_id' => 144, 'test_ref_id' => 3, 'mean' => 1.81, 'sd' => 0.1575],
['control_test_id' => 444, 'control_ref_id' => 127, 'test_ref_id' => 20, 'mean' => 26.8, 'sd' => 3.75],
['control_test_id' => 523, 'control_ref_id' => 163, 'test_ref_id' => 1, 'mean' => 49.8, 'sd' => 3.75],
['control_test_id' => 524, 'control_ref_id' => 163, 'test_ref_id' => 2, 'mean' => 56.4, 'sd' => 4.2],
['control_test_id' => 483, 'control_ref_id' => 144, 'test_ref_id' => 4, 'mean' => 4.17, 'sd' => 0.36],
['control_test_id' => 449, 'control_ref_id' => 133, 'test_ref_id' => 19, 'mean' => 12.55, 'sd' => 1.883],
['control_test_id' => 567, 'control_ref_id' => 179, 'test_ref_id' => 13, 'mean' => 168, 'sd' => 8.4],
['control_test_id' => 568, 'control_ref_id' => 179, 'test_ref_id' => 14, 'mean' => 124, 'sd' => 6.2],
['control_test_id' => 439, 'control_ref_id' => 124, 'test_ref_id' => 19, 'mean' => 3.03, 'sd' => 0.455],
['control_test_id' => 569, 'control_ref_id' => 180, 'test_ref_id' => 1, 'mean' => 49.5, 'sd' => 3.75],
['control_test_id' => 450, 'control_ref_id' => 134, 'test_ref_id' => 13, 'mean' => 166, 'sd' => 8.3],
['control_test_id' => 570, 'control_ref_id' => 180, 'test_ref_id' => 2, 'mean' => 56.4, 'sd' => 4.2],
['control_test_id' => 451, 'control_ref_id' => 134, 'test_ref_id' => 14, 'mean' => 127, 'sd' => 6.35],
['control_test_id' => 452, 'control_ref_id' => 134, 'test_ref_id' => 15, 'mean' => 43, 'sd' => 2.15],
['control_test_id' => 545, 'control_ref_id' => 173, 'test_ref_id' => 1, 'mean' => 150, 'sd' => 12],
['control_test_id' => 546, 'control_ref_id' => 173, 'test_ref_id' => 2, 'mean' => 137, 'sd' => 10.5],
['control_test_id' => 542, 'control_ref_id' => 170, 'test_ref_id' => 18, 'mean' => 2.02, 'sd' => 0.275],
['control_test_id' => 547, 'control_ref_id' => 173, 'test_ref_id' => 6, 'mean' => 126, 'sd' => 9],
['control_test_id' => 453, 'control_ref_id' => 134, 'test_ref_id' => 16, 'mean' => 105, 'sd' => 5.25],
['control_test_id' => 454, 'control_ref_id' => 135, 'test_ref_id' => 13, 'mean' => 232, 'sd' => 11.6],
['control_test_id' => 455, 'control_ref_id' => 135, 'test_ref_id' => 14, 'mean' => 179, 'sd' => 8.95],
['control_test_id' => 456, 'control_ref_id' => 135, 'test_ref_id' => 15, 'mean' => 61, 'sd' => 3.05],
['control_test_id' => 457, 'control_ref_id' => 135, 'test_ref_id' => 16, 'mean' => 146, 'sd' => 7.3],
['control_test_id' => 473, 'control_ref_id' => 143, 'test_ref_id' => 2, 'mean' => 137, 'sd' => 10.5],
['control_test_id' => 474, 'control_ref_id' => 143, 'test_ref_id' => 1, 'mean' => 146, 'sd' => 10.5],
['control_test_id' => 475, 'control_ref_id' => 143, 'test_ref_id' => 7, 'mean' => 4.3, 'sd' => 0.3225],
['control_test_id' => 476, 'control_ref_id' => 143, 'test_ref_id' => 9, 'mean' => 243, 'sd' => 19],
['control_test_id' => 489, 'control_ref_id' => 145, 'test_ref_id' => 37, 'mean' => 0.851, 'sd' => 0.113],
['control_test_id' => 480, 'control_ref_id' => 143, 'test_ref_id' => 5, 'mean' => 4.73, 'sd' => 2.4],
['control_test_id' => 481, 'control_ref_id' => 143, 'test_ref_id' => 36, 'mean' => 3.31, 'sd' => 0.12],
['control_test_id' => 484, 'control_ref_id' => 144, 'test_ref_id' => 10, 'mean' => 162, 'sd' => 20.25],
['control_test_id' => 485, 'control_ref_id' => 144, 'test_ref_id' => 11, 'mean' => 91.7, 'sd' => 6.7],
['control_test_id' => 580, 'control_ref_id' => 182, 'test_ref_id' => 17, 'mean' => 10.71, 'sd' => 0.25],
['control_test_id' => 429, 'control_ref_id' => 121, 'test_ref_id' => 3, 'mean' => 0.83, 'sd' => 0.073],
['control_test_id' => 430, 'control_ref_id' => 121, 'test_ref_id' => 4, 'mean' => 1.53, 'sd' => 0.13],
['control_test_id' => 431, 'control_ref_id' => 121, 'test_ref_id' => 10, 'mean' => 66.6, 'sd' => 5.575],
['control_test_id' => 432, 'control_ref_id' => 121, 'test_ref_id' => 11, 'mean' => 27.5, 'sd' => 2.025],
['control_test_id' => 582, 'control_ref_id' => 184, 'test_ref_id' => 10, 'mean' => 61.65, 'sd' => 5.125],
['control_test_id' => 434, 'control_ref_id' => 121, 'test_ref_id' => 30, 'mean' => 144, 'sd' => 14.5],
['control_test_id' => 583, 'control_ref_id' => 184, 'test_ref_id' => 3, 'mean' => 0.765, 'sd' => 0.0675],
['control_test_id' => 487, 'control_ref_id' => 144, 'test_ref_id' => 30, 'mean' => 220, 'sd' => 22],
['control_test_id' => 488, 'control_ref_id' => 143, 'test_ref_id' => 32, 'mean' => 8.07, 'sd' => 0.4],
['control_test_id' => 490, 'control_ref_id' => 145, 'test_ref_id' => 38, 'mean' => 1.15, 'sd' => 0.15],
['control_test_id' => 494, 'control_ref_id' => 145, 'test_ref_id' => 39, 'mean' => 6.69, 'sd' => 0.89],
['control_test_id' => 495, 'control_ref_id' => 146, 'test_ref_id' => 37, 'mean' => 23.219, 'sd' => 3.096],
['control_test_id' => 496, 'control_ref_id' => 146, 'test_ref_id' => 39, 'mean' => 15.24, 'sd' => 2.03],
['control_test_id' => 497, 'control_ref_id' => 146, 'test_ref_id' => 38, 'mean' => 3.81, 'sd' => 0.51],
['control_test_id' => 514, 'control_ref_id' => 153, 'test_ref_id' => 47, 'mean' => 0.08, 'sd' => 0.13],
['control_test_id' => 515, 'control_ref_id' => 154, 'test_ref_id' => 47, 'mean' => 4.91, 'sd' => 0.9],
['control_test_id' => 516, 'control_ref_id' => 158, 'test_ref_id' => 49, 'mean' => 22.34, 'sd' => 2.98],
['control_test_id' => 517, 'control_ref_id' => 159, 'test_ref_id' => 49, 'mean' => 63.25, 'sd' => 8.43],
['control_test_id' => 518, 'control_ref_id' => 155, 'test_ref_id' => 47, 'mean' => 7.6, 'sd' => 1.39],
['control_test_id' => 519, 'control_ref_id' => 156, 'test_ref_id' => 48, 'mean' => 0.01, 'sd' => 0.13],
['control_test_id' => 520, 'control_ref_id' => 157, 'test_ref_id' => 48, 'mean' => 4.62, 'sd' => 0.77],
['control_test_id' => 525, 'control_ref_id' => 163, 'test_ref_id' => 8, 'mean' => 5.16, 'sd' => 0.355],
['control_test_id' => 526, 'control_ref_id' => 163, 'test_ref_id' => 6, 'mean' => 41.1, 'sd' => 3.075],
['control_test_id' => 527, 'control_ref_id' => 163, 'test_ref_id' => 7, 'mean' => 1.07, 'sd' => 0.08],
['control_test_id' => 528, 'control_ref_id' => 163, 'test_ref_id' => 9, 'mean' => 101, 'sd' => 7.75],
['control_test_id' => 529, 'control_ref_id' => 163, 'test_ref_id' => 5, 'mean' => 3.16, 'sd' => 0.1575],
['control_test_id' => 530, 'control_ref_id' => 163, 'test_ref_id' => 32, 'mean' => 5.07, 'sd' => 0.2539],
['control_test_id' => 535, 'control_ref_id' => 163, 'test_ref_id' => 36, 'mean' => 2.2, 'sd' => 0.0838],
['control_test_id' => 536, 'control_ref_id' => 165, 'test_ref_id' => 17, 'mean' => 5.355, 'sd' => 0.15],
['control_test_id' => 537, 'control_ref_id' => 166, 'test_ref_id' => 17, 'mean' => 10.29, 'sd' => 0.25],
['control_test_id' => 548, 'control_ref_id' => 173, 'test_ref_id' => 7, 'mean' => 4.11, 'sd' => 0.305],
['control_test_id' => 549, 'control_ref_id' => 173, 'test_ref_id' => 8, 'mean' => 10.7, 'sd' => 0.75],
['control_test_id' => 550, 'control_ref_id' => 173, 'test_ref_id' => 9, 'mean' => 241, 'sd' => 18.75],
['control_test_id' => 551, 'control_ref_id' => 173, 'test_ref_id' => 5, 'mean' => 4.74, 'sd' => 0.36],
['control_test_id' => 553, 'control_ref_id' => 175, 'test_ref_id' => 19, 'mean' => 3.05, 'sd' => 0.457],
['control_test_id' => 554, 'control_ref_id' => 174, 'test_ref_id' => 19, 'mean' => 12.53, 'sd' => 1.88],
['control_test_id' => 555, 'control_ref_id' => 176, 'test_ref_id' => 43, 'mean' => 34.29, 'sd' => 2.8],
['control_test_id' => 559, 'control_ref_id' => 163, 'test_ref_id' => 53, 'mean' => 4.46, 'sd' => 0.22],
['control_test_id' => 560, 'control_ref_id' => 173, 'test_ref_id' => 53, 'mean' => 9.08, 'sd' => 0.47],
['control_test_id' => 577, 'control_ref_id' => 180, 'test_ref_id' => 32, 'mean' => 5.12, 'sd' => 0.256],
['control_test_id' => 584, 'control_ref_id' => 184, 'test_ref_id' => 4, 'mean' => 1.33, 'sd' => 0.115],
['control_test_id' => 585, 'control_ref_id' => 184, 'test_ref_id' => 11, 'mean' => 31.98, 'sd' => 2.325],
['control_test_id' => 586, 'control_ref_id' => 184, 'test_ref_id' => 30, 'mean' => 145, 'sd' => 14.5],
['control_test_id' => 587, 'control_ref_id' => 185, 'test_ref_id' => 17, 'mean' => 5.67, 'sd' => 0.15],
['control_test_id' => 588, 'control_ref_id' => 186, 'test_ref_id' => 17, 'mean' => 10.29, 'sd' => 0.25],
['control_test_id' => 477, 'control_ref_id' => 143, 'test_ref_id' => 8, 'mean' => 10.4, 'sd' => 0.7],
['control_test_id' => 478, 'control_ref_id' => 143, 'test_ref_id' => 6, 'mean' => 125, 'sd' => 9],
['control_test_id' => 499, 'control_ref_id' => 147, 'test_ref_id' => 40, 'mean' => 2.7, 'sd' => 0.36],
['control_test_id' => 500, 'control_ref_id' => 147, 'test_ref_id' => 41, 'mean' => 1.125, 'sd' => 0.15],
['control_test_id' => 501, 'control_ref_id' => 147, 'test_ref_id' => 42, 'mean' => 4.38, 'sd' => 0.58],
['control_test_id' => 502, 'control_ref_id' => 147, 'test_ref_id' => 43, 'mean' => 10.09, 'sd' => 1.35],
['control_test_id' => 503, 'control_ref_id' => 147, 'test_ref_id' => 44, 'mean' => 29.43, 'sd' => 3.92],
['control_test_id' => 592, 'control_ref_id' => 187, 'test_ref_id' => 3, 'mean' => 2.19, 'sd' => 0.19],
['control_test_id' => 362, 'control_ref_id' => 98, 'test_ref_id' => 3, 'mean' => 1.8, 'sd' => 0.232],
['control_test_id' => 363, 'control_ref_id' => 98, 'test_ref_id' => 4, 'mean' => 5.02, 'sd' => 0.652],
['control_test_id' => 469, 'control_ref_id' => 139, 'test_ref_id' => 20, 'mean' => 26.7, 'sd' => 3.75],
['control_test_id' => 593, 'control_ref_id' => 187, 'test_ref_id' => 4, 'mean' => 4.63, 'sd' => 0.403],
['control_test_id' => 594, 'control_ref_id' => 187, 'test_ref_id' => 10, 'mean' => 151, 'sd' => 12.5],
['control_test_id' => 595, 'control_ref_id' => 187, 'test_ref_id' => 11, 'mean' => 88.7, 'sd' => 6.58],
['control_test_id' => 596, 'control_ref_id' => 187, 'test_ref_id' => 30, 'mean' => 216, 'sd' => 21.5],
['control_test_id' => 470, 'control_ref_id' => 140, 'test_ref_id' => 20, 'mean' => 104.8, 'sd' => 14.6],
['control_test_id' => 531, 'control_ref_id' => 164, 'test_ref_id' => 13, 'mean' => 233, 'sd' => 11.65],
['control_test_id' => 532, 'control_ref_id' => 164, 'test_ref_id' => 14, 'mean' => 174, 'sd' => 8.7],
['control_test_id' => 557, 'control_ref_id' => 173, 'test_ref_id' => 36, 'mean' => 3.26, 'sd' => 0.18],
['control_test_id' => 533, 'control_ref_id' => 164, 'test_ref_id' => 15, 'mean' => 61, 'sd' => 3.05],
['control_test_id' => 534, 'control_ref_id' => 164, 'test_ref_id' => 16, 'mean' => 147, 'sd' => 7.35],
['control_test_id' => 384, 'control_ref_id' => 98, 'test_ref_id' => 11, 'mean' => 95.6, 'sd' => 10.625],
['control_test_id' => 581, 'control_ref_id' => 183, 'test_ref_id' => 18, 'mean' => 1.94, 'sd' => 0.26],
['control_test_id' => 579, 'control_ref_id' => 181, 'test_ref_id' => 17, 'mean' => 5.775, 'sd' => 0.15],
['control_test_id' => 365, 'control_ref_id' => 98, 'test_ref_id' => 10, 'mean' => 188, 'sd' => 23.5],
['control_test_id' => 367, 'control_ref_id' => 98, 'test_ref_id' => 21, 'mean' => 12.6, 'sd' => 0.675],
['control_test_id' => 368, 'control_ref_id' => 98, 'test_ref_id' => 29, 'mean' => 7.66, 'sd' => 0.69],
['control_test_id' => 369, 'control_ref_id' => 98, 'test_ref_id' => 31, 'mean' => 111, 'sd' => 11.025],
['control_test_id' => 370, 'control_ref_id' => 98, 'test_ref_id' => 30, 'mean' => 252, 'sd' => 25.25],
['control_test_id' => 505, 'control_ref_id' => 148, 'test_ref_id' => 40, 'mean' => 27, 'sd' => 3.6],
['control_test_id' => 506, 'control_ref_id' => 148, 'test_ref_id' => 41, 'mean' => 15.277, 'sd' => 2.037],
['control_test_id' => 507, 'control_ref_id' => 148, 'test_ref_id' => 42, 'mean' => 47.6, 'sd' => 6.35],
['control_test_id' => 508, 'control_ref_id' => 148, 'test_ref_id' => 43, 'mean' => 58.51, 'sd' => 7.8],
['control_test_id' => 509, 'control_ref_id' => 148, 'test_ref_id' => 44, 'mean' => 193.03, 'sd' => 25.74],
['control_test_id' => 510, 'control_ref_id' => 149, 'test_ref_id' => 45, 'mean' => 0.001, 'sd' => 0.017],
['control_test_id' => 511, 'control_ref_id' => 150, 'test_ref_id' => 45, 'mean' => 0.581, 'sd' => 0.077],
['control_test_id' => 512, 'control_ref_id' => 151, 'test_ref_id' => 46, 'mean' => 0, 'sd' => 1.67],
['control_test_id' => 513, 'control_ref_id' => 152, 'test_ref_id' => 46, 'mean' => 19.98, 'sd' => 3],
['control_test_id' => 538, 'control_ref_id' => 167, 'test_ref_id' => 52, 'mean' => 1.08, 'sd' => 0.1],
['control_test_id' => 539, 'control_ref_id' => 168, 'test_ref_id' => 39, 'mean' => 6.6485, 'sd' => 0.7125],
['control_test_id' => 540, 'control_ref_id' => 160, 'test_ref_id' => 50, 'mean' => 34.4, 'sd' => 3.51],
['control_test_id' => 552, 'control_ref_id' => 173, 'test_ref_id' => 32, 'mean' => 8.01, 'sd' => 0.6],
['control_test_id' => 572, 'control_ref_id' => 180, 'test_ref_id' => 9, 'mean' => 101.5, 'sd' => 7.75],
['control_test_id' => 578, 'control_ref_id' => 180, 'test_ref_id' => 5, 'mean' => 3.16, 'sd' => 0.158],
['control_test_id' => 571, 'control_ref_id' => 180, 'test_ref_id' => 7, 'mean' => 1.08, 'sd' => 0.0825],
['control_test_id' => 573, 'control_ref_id' => 180, 'test_ref_id' => 8, 'mean' => 5.225, 'sd' => 0.3525],
['control_test_id' => 574, 'control_ref_id' => 180, 'test_ref_id' => 6, 'mean' => 40.7, 'sd' => 3.05],
['control_test_id' => 590, 'control_ref_id' => 180, 'test_ref_id' => 53, 'mean' => 4.52, 'sd' => 0.22],
['control_test_id' => 591, 'control_ref_id' => 180, 'test_ref_id' => 36, 'mean' => 2.2, 'sd' => 0.083],
];
$this->db->table('control_tests')->insertBatch($data);
$data = [
['result_id' => 28, 'control_ref_id' => 1, 'test_ref_id' => 1, 'resdate' => '2022-01-03 00:00:00', 'resvalue' => '152.868220727426', 'rescomment' => null],
['result_id' => 29, 'control_ref_id' => 1, 'test_ref_id' => 2, 'resdate' => '2022-01-03 00:00:00', 'resvalue' => '118.684360070769', 'rescomment' => null],
['result_id' => 30, 'control_ref_id' => 1, 'test_ref_id' => 3, 'resdate' => '2022-01-03 00:00:00', 'resvalue' => '1.78676744546881', 'rescomment' => null],
['result_id' => 31, 'control_ref_id' => 1, 'test_ref_id' => 4, 'resdate' => '2022-01-03 00:00:00', 'resvalue' => '4.88788440216215', 'rescomment' => null],
['result_id' => 32, 'control_ref_id' => 1, 'test_ref_id' => 5, 'resdate' => '2022-01-03 00:00:00', 'resvalue' => '4.54649638396286', 'rescomment' => null],
['result_id' => 33, 'control_ref_id' => 1, 'test_ref_id' => 6, 'resdate' => '2022-01-03 00:00:00', 'resvalue' => '68.9277965359498', 'rescomment' => null],
['result_id' => 34, 'control_ref_id' => 1, 'test_ref_id' => 7, 'resdate' => '2022-01-03 00:00:00', 'resvalue' => '4.7616948568887', 'rescomment' => null],
['result_id' => 35, 'control_ref_id' => 1, 'test_ref_id' => 8, 'resdate' => '2022-01-03 00:00:00', 'resvalue' => '8.2805131289407', 'rescomment' => null],
['result_id' => 36, 'control_ref_id' => 1, 'test_ref_id' => 9, 'resdate' => '2022-01-03 00:00:00', 'resvalue' => '255.718750547819', 'rescomment' => null],
['result_id' => 37, 'control_ref_id' => 1, 'test_ref_id' => 10, 'resdate' => '2022-01-03 00:00:00', 'resvalue' => '185.86621742091', 'rescomment' => null],
['result_id' => 38, 'control_ref_id' => 1, 'test_ref_id' => 11, 'resdate' => '2022-01-03 00:00:00', 'resvalue' => '96.0370738667909', 'rescomment' => null],
['result_id' => 39, 'control_ref_id' => 1, 'test_ref_id' => 12, 'resdate' => '2022-01-03 00:00:00', 'resvalue' => '7.26130670682815', 'rescomment' => null],
['result_id' => 40, 'control_ref_id' => 2, 'test_ref_id' => 13, 'resdate' => '2022-01-03 00:00:00', 'resvalue' => '158.320085275538', 'rescomment' => null],
['result_id' => 41, 'control_ref_id' => 2, 'test_ref_id' => 14, 'resdate' => '2022-01-03 00:00:00', 'resvalue' => '123.642030022172', 'rescomment' => null],
['result_id' => 42, 'control_ref_id' => 2, 'test_ref_id' => 15, 'resdate' => '2022-01-03 00:00:00', 'resvalue' => '36.9505985250087', 'rescomment' => null],
['result_id' => 43, 'control_ref_id' => 2, 'test_ref_id' => 16, 'resdate' => '2022-01-03 00:00:00', 'resvalue' => '96.5175241884342', 'rescomment' => null],
['result_id' => 44, 'control_ref_id' => 2, 'test_ref_id' => 14, 'resdate' => '2022-01-03 00:00:00', 'resvalue' => '110.353601999312', 'rescomment' => null],
['result_id' => 45, 'control_ref_id' => 2, 'test_ref_id' => 15, 'resdate' => '2022-01-03 00:00:00', 'resvalue' => '40.9599586941077', 'rescomment' => null],
['result_id' => 46, 'control_ref_id' => 3, 'test_ref_id' => 17, 'resdate' => '2022-01-03 00:00:00', 'resvalue' => '1528049849.3', 'rescomment' => null],
['result_id' => 47, 'control_ref_id' => 3, 'test_ref_id' => 17, 'resdate' => '2022-01-03 00:00:00', 'resvalue' => '5.1', 'rescomment' => null],
['result_id' => 48, 'control_ref_id' => 4, 'test_ref_id' => 13, 'resdate' => '2022-01-03 00:00:00', 'resvalue' => '215.383147793402', 'rescomment' => null],
['result_id' => 49, 'control_ref_id' => 4, 'test_ref_id' => 14, 'resdate' => '2022-01-03 00:00:00', 'resvalue' => '183.063991935605', 'rescomment' => null],
['result_id' => 50, 'control_ref_id' => 4, 'test_ref_id' => 15, 'resdate' => '2022-01-03 00:00:00', 'resvalue' => '52.9496711121656', 'rescomment' => null],
['result_id' => 51, 'control_ref_id' => 4, 'test_ref_id' => 16, 'resdate' => '2022-01-03 00:00:00', 'resvalue' => '133.934963501757', 'rescomment' => null],
['result_id' => 52, 'control_ref_id' => 4, 'test_ref_id' => 14, 'resdate' => '2022-01-03 00:00:00', 'resvalue' => '158.484164984758', 'rescomment' => null],
['result_id' => 53, 'control_ref_id' => 4, 'test_ref_id' => 15, 'resdate' => '2022-01-03 00:00:00', 'resvalue' => '56.8818601408997', 'rescomment' => null],
['result_id' => 54, 'control_ref_id' => 5, 'test_ref_id' => 17, 'resdate' => '2022-01-03 00:00:00', 'resvalue' => '1518899850.3', 'rescomment' => null],
['result_id' => 55, 'control_ref_id' => 5, 'test_ref_id' => 17, 'resdate' => '2022-01-03 00:00:00', 'resvalue' => '10.5', 'rescomment' => null],
['result_id' => 56, 'control_ref_id' => 5, 'test_ref_id' => 17, 'resdate' => '2022-01-03 00:00:00', 'resvalue' => '10.5', 'rescomment' => null],
['result_id' => 57, 'control_ref_id' => 6, 'test_ref_id' => 1, 'resdate' => '2022-01-03 00:00:00', 'resvalue' => '48.9562924866303', 'rescomment' => null],
['result_id' => 58, 'control_ref_id' => 6, 'test_ref_id' => 2, 'resdate' => '2022-01-03 00:00:00', 'resvalue' => '52.1440402715625', 'rescomment' => null],
['result_id' => 59, 'control_ref_id' => 6, 'test_ref_id' => 3, 'resdate' => '2022-01-03 00:00:00', 'resvalue' => '0.827525226237078', 'rescomment' => null],
['result_id' => 60, 'control_ref_id' => 6, 'test_ref_id' => 4, 'resdate' => '2022-01-03 00:00:00', 'resvalue' => '1.43268122033837', 'rescomment' => null],
['result_id' => 61, 'control_ref_id' => 6, 'test_ref_id' => 5, 'resdate' => '2022-01-03 00:00:00', 'resvalue' => '3.32791020761993', 'rescomment' => null],
['result_id' => 62, 'control_ref_id' => 6, 'test_ref_id' => 6, 'resdate' => '2022-01-03 00:00:00', 'resvalue' => '20.1899916884103', 'rescomment' => null],
['result_id' => 63, 'control_ref_id' => 6, 'test_ref_id' => 7, 'resdate' => '2022-01-03 00:00:00', 'resvalue' => '0.942164469720469', 'rescomment' => null],
['result_id' => 64, 'control_ref_id' => 6, 'test_ref_id' => 8, 'resdate' => '2022-01-03 00:00:00', 'resvalue' => '4.92672863627875', 'rescomment' => null],
['result_id' => 65, 'control_ref_id' => 6, 'test_ref_id' => 9, 'resdate' => '2022-01-03 00:00:00', 'resvalue' => '97.9752041498986', 'rescomment' => null],
['result_id' => 66, 'control_ref_id' => 6, 'test_ref_id' => 10, 'resdate' => '2022-01-03 00:00:00', 'resvalue' => '82', 'rescomment' => null],
['result_id' => 67, 'control_ref_id' => 6, 'test_ref_id' => 11, 'resdate' => '2022-01-03 00:00:00', 'resvalue' => '55.6067623790927', 'rescomment' => null],
['result_id' => 68, 'control_ref_id' => 7, 'test_ref_id' => 18, 'resdate' => '2022-01-03 00:00:00', 'resvalue' => '1.3534129858017', 'rescomment' => null],
['result_id' => 69, 'control_ref_id' => 8, 'test_ref_id' => 18, 'resdate' => '2022-01-03 00:00:00', 'resvalue' => '2.92454624176025', 'rescomment' => null],
['result_id' => 70, 'control_ref_id' => 9, 'test_ref_id' => 1, 'resdate' => '2022-01-03 00:00:00', 'resvalue' => '41.9241811453099', 'rescomment' => null],
['result_id' => 71, 'control_ref_id' => 9, 'test_ref_id' => 2, 'resdate' => '2022-01-03 00:00:00', 'resvalue' => '50.2606047539432', 'rescomment' => null],
['result_id' => 72, 'control_ref_id' => 9, 'test_ref_id' => 3, 'resdate' => '2022-01-03 00:00:00', 'resvalue' => '0.618850628140718', 'rescomment' => null],
['result_id' => 73, 'control_ref_id' => 9, 'test_ref_id' => 4, 'resdate' => '2022-01-03 00:00:00', 'resvalue' => '1.64659256568823', 'rescomment' => null],
['result_id' => 74, 'control_ref_id' => 9, 'test_ref_id' => 5, 'resdate' => '2022-01-03 00:00:00', 'resvalue' => '3.37936528279952', 'rescomment' => null],
['result_id' => 75, 'control_ref_id' => 9, 'test_ref_id' => 6, 'resdate' => '2022-01-03 00:00:00', 'resvalue' => '19.9687141929191', 'rescomment' => null],
['result_id' => 76, 'control_ref_id' => 9, 'test_ref_id' => 7, 'resdate' => '2022-01-03 00:00:00', 'resvalue' => '1.25401465739322', 'rescomment' => null],
['result_id' => 77, 'control_ref_id' => 9, 'test_ref_id' => 8, 'resdate' => '2022-01-03 00:00:00', 'resvalue' => '5.20068765776226', 'rescomment' => null],
['result_id' => 78, 'control_ref_id' => 9, 'test_ref_id' => 9, 'resdate' => '2022-01-03 00:00:00', 'resvalue' => '85.8656412403935', 'rescomment' => null],
['result_id' => 79, 'control_ref_id' => 9, 'test_ref_id' => 10, 'resdate' => '2022-01-03 00:00:00', 'resvalue' => '73.7679469620088', 'rescomment' => null],
['result_id' => 80, 'control_ref_id' => 9, 'test_ref_id' => 11, 'resdate' => '2022-01-03 00:00:00', 'resvalue' => '32.6032920741649', 'rescomment' => null],
['result_id' => 81, 'control_ref_id' => 9, 'test_ref_id' => 12, 'resdate' => '2022-01-03 00:00:00', 'resvalue' => '4.60016347657495', 'rescomment' => null],
['result_id' => 82, 'control_ref_id' => 10, 'test_ref_id' => 19, 'resdate' => '2022-01-03 00:00:00', 'resvalue' => '3.07556349669703', 'rescomment' => null],
['result_id' => 83, 'control_ref_id' => 11, 'test_ref_id' => 19, 'resdate' => '2022-01-03 00:00:00', 'resvalue' => '14.2416023954004', 'rescomment' => null],
['result_id' => 84, 'control_ref_id' => 1, 'test_ref_id' => 1, 'resdate' => '2022-01-04 00:00:00', 'resvalue' => '151.987144896542', 'rescomment' => null],
['result_id' => 85, 'control_ref_id' => 1, 'test_ref_id' => 2, 'resdate' => '2022-01-04 00:00:00', 'resvalue' => '118.037436722317', 'rescomment' => null],
['result_id' => 86, 'control_ref_id' => 1, 'test_ref_id' => 3, 'resdate' => '2022-01-04 00:00:00', 'resvalue' => '1.7947151556153', 'rescomment' => null],
['result_id' => 87, 'control_ref_id' => 1, 'test_ref_id' => 4, 'resdate' => '2022-01-04 00:00:00', 'resvalue' => '4.73906612533412', 'rescomment' => null],
['result_id' => 88, 'control_ref_id' => 1, 'test_ref_id' => 5, 'resdate' => '2022-01-04 00:00:00', 'resvalue' => '4.60361234521986', 'rescomment' => null],
['result_id' => 89, 'control_ref_id' => 1, 'test_ref_id' => 6, 'resdate' => '2022-01-04 00:00:00', 'resvalue' => '72.6643107473908', 'rescomment' => null],
['result_id' => 90, 'control_ref_id' => 1, 'test_ref_id' => 7, 'resdate' => '2022-01-04 00:00:00', 'resvalue' => '4.63980962604914', 'rescomment' => null],
['result_id' => 91, 'control_ref_id' => 1, 'test_ref_id' => 8, 'resdate' => '2022-01-04 00:00:00', 'resvalue' => '8.38141623646488', 'rescomment' => null],
['result_id' => 92, 'control_ref_id' => 1, 'test_ref_id' => 9, 'resdate' => '2022-01-04 00:00:00', 'resvalue' => '264.978406417832', 'rescomment' => null],
['result_id' => 93, 'control_ref_id' => 1, 'test_ref_id' => 10, 'resdate' => '2022-01-04 00:00:00', 'resvalue' => '181.555224534248', 'rescomment' => null],
['result_id' => 94, 'control_ref_id' => 1, 'test_ref_id' => 11, 'resdate' => '2022-01-04 00:00:00', 'resvalue' => '96.2859292539928', 'rescomment' => null],
['result_id' => 95, 'control_ref_id' => 1, 'test_ref_id' => 12, 'resdate' => '2022-01-04 00:00:00', 'resvalue' => '6.9194402361869', 'rescomment' => null],
['result_id' => 96, 'control_ref_id' => 1, 'test_ref_id' => 2, 'resdate' => '2022-01-04 00:00:00', 'resvalue' => '110.231586595837', 'rescomment' => null],
['result_id' => 97, 'control_ref_id' => 1, 'test_ref_id' => 8, 'resdate' => '2022-01-04 00:00:00', 'resvalue' => '7.83563261140536', 'rescomment' => null],
['result_id' => 98, 'control_ref_id' => 2, 'test_ref_id' => 13, 'resdate' => '2022-01-04 00:00:00', 'resvalue' => '162.230018707428', 'rescomment' => null],
['result_id' => 99, 'control_ref_id' => 2, 'test_ref_id' => 14, 'resdate' => '2022-01-04 00:00:00', 'resvalue' => '130.52137139783', 'rescomment' => null],
['result_id' => 100, 'control_ref_id' => 2, 'test_ref_id' => 15, 'resdate' => '2022-01-04 00:00:00', 'resvalue' => '40.1447263115978', 'rescomment' => null],
['result_id' => 101, 'control_ref_id' => 2, 'test_ref_id' => 16, 'resdate' => '2022-01-04 00:00:00', 'resvalue' => '101.152360213402', 'rescomment' => null],
['result_id' => 102, 'control_ref_id' => 2, 'test_ref_id' => 14, 'resdate' => '2022-01-04 00:00:00', 'resvalue' => '102.256365254374', 'rescomment' => null],
['result_id' => 103, 'control_ref_id' => 2, 'test_ref_id' => 14, 'resdate' => '2022-01-04 00:00:00', 'resvalue' => '104.629167708808', 'rescomment' => null],
['result_id' => 104, 'control_ref_id' => 2, 'test_ref_id' => 14, 'resdate' => '2022-01-04 00:00:00', 'resvalue' => '82.6663002141555', 'rescomment' => null],
['result_id' => 105, 'control_ref_id' => 2, 'test_ref_id' => 14, 'resdate' => '2022-01-04 00:00:00', 'resvalue' => '116.848292060971', 'rescomment' => null],
['result_id' => 106, 'control_ref_id' => 3, 'test_ref_id' => 17, 'resdate' => '2022-01-04 00:00:00', 'resvalue' => '6', 'rescomment' => null],
['result_id' => 107, 'control_ref_id' => 3, 'test_ref_id' => 17, 'resdate' => '2022-01-04 00:00:00', 'resvalue' => '4.9', 'rescomment' => null],
['result_id' => 108, 'control_ref_id' => 4, 'test_ref_id' => 13, 'resdate' => '2022-01-04 00:00:00', 'resvalue' => '225.968857118997', 'rescomment' => null],
['result_id' => 109, 'control_ref_id' => 4, 'test_ref_id' => 14, 'resdate' => '2022-01-04 00:00:00', 'resvalue' => '174.601513698878', 'rescomment' => null],
['result_id' => 110, 'control_ref_id' => 4, 'test_ref_id' => 15, 'resdate' => '2022-01-04 00:00:00', 'resvalue' => '60.5069551717738', 'rescomment' => null],
['result_id' => 111, 'control_ref_id' => 4, 'test_ref_id' => 16, 'resdate' => '2022-01-04 00:00:00', 'resvalue' => '139.447942846202', 'rescomment' => null],
['result_id' => 112, 'control_ref_id' => 4, 'test_ref_id' => 14, 'resdate' => '2022-01-04 00:00:00', 'resvalue' => '143.31010007369', 'rescomment' => null],
['result_id' => 113, 'control_ref_id' => 4, 'test_ref_id' => 14, 'resdate' => '2022-01-04 00:00:00', 'resvalue' => '144.761372351536', 'rescomment' => null],
['result_id' => 114, 'control_ref_id' => 4, 'test_ref_id' => 14, 'resdate' => '2022-01-04 00:00:00', 'resvalue' => '115.071814150515', 'rescomment' => null],
['result_id' => 115, 'control_ref_id' => 4, 'test_ref_id' => 14, 'resdate' => '2022-01-04 00:00:00', 'resvalue' => '161.317934555282', 'rescomment' => null],
['result_id' => 116, 'control_ref_id' => 5, 'test_ref_id' => 17, 'resdate' => '2022-01-04 00:00:00', 'resvalue' => '10.2', 'rescomment' => null],
['result_id' => 117, 'control_ref_id' => 6, 'test_ref_id' => 1, 'resdate' => '2022-01-04 00:00:00', 'resvalue' => '49.5516111762261', 'rescomment' => null],
['result_id' => 118, 'control_ref_id' => 6, 'test_ref_id' => 2, 'resdate' => '2022-01-04 00:00:00', 'resvalue' => '52.3007836764823', 'rescomment' => null],
['result_id' => 119, 'control_ref_id' => 6, 'test_ref_id' => 3, 'resdate' => '2022-01-04 00:00:00', 'resvalue' => '0.826492230714472', 'rescomment' => null],
['result_id' => 120, 'control_ref_id' => 6, 'test_ref_id' => 4, 'resdate' => '2022-01-04 00:00:00', 'resvalue' => '1.4488869704763', 'rescomment' => null],
['result_id' => 121, 'control_ref_id' => 6, 'test_ref_id' => 5, 'resdate' => '2022-01-04 00:00:00', 'resvalue' => '3.44673661899837', 'rescomment' => null],
['result_id' => 122, 'control_ref_id' => 6, 'test_ref_id' => 6, 'resdate' => '2022-01-04 00:00:00', 'resvalue' => '20.730181610828', 'rescomment' => null],
['result_id' => 123, 'control_ref_id' => 6, 'test_ref_id' => 7, 'resdate' => '2022-01-04 00:00:00', 'resvalue' => '0.931063374396039', 'rescomment' => null],
['result_id' => 124, 'control_ref_id' => 6, 'test_ref_id' => 8, 'resdate' => '2022-01-04 00:00:00', 'resvalue' => '4.90811693843901', 'rescomment' => null],
['result_id' => 125, 'control_ref_id' => 6, 'test_ref_id' => 9, 'resdate' => '2022-01-04 00:00:00', 'resvalue' => '101.930759918121', 'rescomment' => null],
['result_id' => 126, 'control_ref_id' => 6, 'test_ref_id' => 10, 'resdate' => '2022-01-04 00:00:00', 'resvalue' => '75.5729386133723', 'rescomment' => null],
['result_id' => 127, 'control_ref_id' => 6, 'test_ref_id' => 11, 'resdate' => '2022-01-04 00:00:00', 'resvalue' => '56.5900268982851', 'rescomment' => null],
['result_id' => 128, 'control_ref_id' => 6, 'test_ref_id' => 10, 'resdate' => '2022-01-04 00:00:00', 'resvalue' => '102.528037735786', 'rescomment' => null],
['result_id' => 129, 'control_ref_id' => 12, 'test_ref_id' => 20, 'resdate' => '2022-01-04 00:00:00', 'resvalue' => '51.0905355215073', 'rescomment' => null],
['result_id' => 130, 'control_ref_id' => 12, 'test_ref_id' => 20, 'resdate' => '2022-01-04 00:00:00', 'resvalue' => '37.0758876204491', 'rescomment' => null],
['result_id' => 131, 'control_ref_id' => 13, 'test_ref_id' => 20, 'resdate' => '2022-01-04 00:00:00', 'resvalue' => '104.115432500839', 'rescomment' => null],
['result_id' => 132, 'control_ref_id' => 13, 'test_ref_id' => 20, 'resdate' => '2022-01-04 00:00:00', 'resvalue' => '126.745772361755', 'rescomment' => null],
['result_id' => 133, 'control_ref_id' => 9, 'test_ref_id' => 1, 'resdate' => '2022-01-04 00:00:00', 'resvalue' => '44.2766951686621', 'rescomment' => null],
['result_id' => 134, 'control_ref_id' => 9, 'test_ref_id' => 2, 'resdate' => '2022-01-04 00:00:00', 'resvalue' => '52.3172542490699', 'rescomment' => null],
['result_id' => 135, 'control_ref_id' => 9, 'test_ref_id' => 3, 'resdate' => '2022-01-04 00:00:00', 'resvalue' => '0.611564331171467', 'rescomment' => null],
['result_id' => 136, 'control_ref_id' => 9, 'test_ref_id' => 4, 'resdate' => '2022-01-04 00:00:00', 'resvalue' => '1.61071374749995', 'rescomment' => null],
['result_id' => 137, 'control_ref_id' => 9, 'test_ref_id' => 5, 'resdate' => '2022-01-04 00:00:00', 'resvalue' => '3.40677107339127', 'rescomment' => null],
['result_id' => 138, 'control_ref_id' => 9, 'test_ref_id' => 6, 'resdate' => '2022-01-04 00:00:00', 'resvalue' => '20.3040445233696', 'rescomment' => null],
['result_id' => 139, 'control_ref_id' => 9, 'test_ref_id' => 7, 'resdate' => '2022-01-04 00:00:00', 'resvalue' => '1.18843758036108', 'rescomment' => null],
['result_id' => 140, 'control_ref_id' => 9, 'test_ref_id' => 8, 'resdate' => '2022-01-04 00:00:00', 'resvalue' => '5.30604556512929', 'rescomment' => null],
['result_id' => 141, 'control_ref_id' => 9, 'test_ref_id' => 9, 'resdate' => '2022-01-04 00:00:00', 'resvalue' => '89.4499417480113', 'rescomment' => null],
['result_id' => 142, 'control_ref_id' => 9, 'test_ref_id' => 10, 'resdate' => '2022-01-04 00:00:00', 'resvalue' => '74.0960687372425', 'rescomment' => null],
['result_id' => 143, 'control_ref_id' => 9, 'test_ref_id' => 11, 'resdate' => '2022-01-04 00:00:00', 'resvalue' => '32.4566384751244', 'rescomment' => null],
['result_id' => 144, 'control_ref_id' => 9, 'test_ref_id' => 12, 'resdate' => '2022-01-04 00:00:00', 'resvalue' => '4.48437909776323', 'rescomment' => null],
['result_id' => 145, 'control_ref_id' => 9, 'test_ref_id' => 2, 'resdate' => '2022-01-04 00:00:00', 'resvalue' => '50.9667682640676', 'rescomment' => null],
['result_id' => 146, 'control_ref_id' => 9, 'test_ref_id' => 8, 'resdate' => '2022-01-04 00:00:00', 'resvalue' => '4.93310398630639', 'rescomment' => null],
['result_id' => 147, 'control_ref_id' => 1, 'test_ref_id' => 1, 'resdate' => '2022-01-05 00:00:00', 'resvalue' => '145.49911151053', 'rescomment' => null],
['result_id' => 148, 'control_ref_id' => 1, 'test_ref_id' => 2, 'resdate' => '2022-01-05 00:00:00', 'resvalue' => '113.383579655159', 'rescomment' => null],
['result_id' => 149, 'control_ref_id' => 1, 'test_ref_id' => 3, 'resdate' => '2022-01-05 00:00:00', 'resvalue' => '1.78951109759924', 'rescomment' => null],
['result_id' => 150, 'control_ref_id' => 1, 'test_ref_id' => 4, 'resdate' => '2022-01-05 00:00:00', 'resvalue' => '4.93788942107251', 'rescomment' => null],
['result_id' => 151, 'control_ref_id' => 1, 'test_ref_id' => 5, 'resdate' => '2022-01-05 00:00:00', 'resvalue' => '4.6838893149483', 'rescomment' => null],
['result_id' => 152, 'control_ref_id' => 1, 'test_ref_id' => 6, 'resdate' => '2022-01-05 00:00:00', 'resvalue' => '71.2844487736166', 'rescomment' => null],
['result_id' => 153, 'control_ref_id' => 1, 'test_ref_id' => 7, 'resdate' => '2022-01-05 00:00:00', 'resvalue' => '4.66921401448631', 'rescomment' => null],
['result_id' => 154, 'control_ref_id' => 1, 'test_ref_id' => 8, 'resdate' => '2022-01-05 00:00:00', 'resvalue' => '7.75508570982025', 'rescomment' => null],
['result_id' => 155, 'control_ref_id' => 1, 'test_ref_id' => 9, 'resdate' => '2022-01-05 00:00:00', 'resvalue' => '259.337398768362', 'rescomment' => null],
['result_id' => 156, 'control_ref_id' => 1, 'test_ref_id' => 10, 'resdate' => '2022-01-05 00:00:00', 'resvalue' => '237.342516597661', 'rescomment' => null],
['result_id' => 157, 'control_ref_id' => 1, 'test_ref_id' => 11, 'resdate' => '2022-01-05 00:00:00', 'resvalue' => '95.377689131424', 'rescomment' => null],
['result_id' => 158, 'control_ref_id' => 1, 'test_ref_id' => 12, 'resdate' => '2022-01-05 00:00:00', 'resvalue' => '6.33840481787399', 'rescomment' => null],
['result_id' => 159, 'control_ref_id' => 1, 'test_ref_id' => 10, 'resdate' => '2022-01-05 00:00:00', 'resvalue' => '254.058423430058', 'rescomment' => null],
['result_id' => 160, 'control_ref_id' => 1, 'test_ref_id' => 12, 'resdate' => '2022-01-05 00:00:00', 'resvalue' => '7.61797516866643', 'rescomment' => null],
['result_id' => 161, 'control_ref_id' => 1, 'test_ref_id' => 10, 'resdate' => '2022-01-05 00:00:00', 'resvalue' => '243.755676108857', 'rescomment' => null],
['result_id' => 162, 'control_ref_id' => 1, 'test_ref_id' => 10, 'resdate' => '2022-01-05 00:00:00', 'resvalue' => '193.063562956371', 'rescomment' => null],
['result_id' => 163, 'control_ref_id' => 2, 'test_ref_id' => 13, 'resdate' => '2022-01-05 00:00:00', 'resvalue' => '156.243798489035', 'rescomment' => null],
['result_id' => 164, 'control_ref_id' => 2, 'test_ref_id' => 14, 'resdate' => '2022-01-05 00:00:00', 'resvalue' => '119.907027927493', 'rescomment' => null],
['result_id' => 165, 'control_ref_id' => 2, 'test_ref_id' => 15, 'resdate' => '2022-01-05 00:00:00', 'resvalue' => '40.447059699393', 'rescomment' => null],
['result_id' => 166, 'control_ref_id' => 2, 'test_ref_id' => 16, 'resdate' => '2022-01-05 00:00:00', 'resvalue' => '102.231291242292', 'rescomment' => null],
['result_id' => 167, 'control_ref_id' => 3, 'test_ref_id' => 17, 'resdate' => '2022-01-05 00:00:00', 'resvalue' => '5.3', 'rescomment' => null],
['result_id' => 168, 'control_ref_id' => 3, 'test_ref_id' => 17, 'resdate' => '2022-01-05 00:00:00', 'resvalue' => '1921499810', 'rescomment' => null],
['result_id' => 169, 'control_ref_id' => 3, 'test_ref_id' => 17, 'resdate' => '2022-01-05 00:00:00', 'resvalue' => '5.1', 'rescomment' => null],
['result_id' => 170, 'control_ref_id' => 4, 'test_ref_id' => 13, 'resdate' => '2022-01-05 00:00:00', 'resvalue' => '219.038828305261', 'rescomment' => null],
['result_id' => 171, 'control_ref_id' => 4, 'test_ref_id' => 14, 'resdate' => '2022-01-05 00:00:00', 'resvalue' => '166.155678322747', 'rescomment' => null],
['result_id' => 172, 'control_ref_id' => 4, 'test_ref_id' => 15, 'resdate' => '2022-01-05 00:00:00', 'resvalue' => '56.8925909121002', 'rescomment' => null],
['result_id' => 173, 'control_ref_id' => 4, 'test_ref_id' => 16, 'resdate' => '2022-01-05 00:00:00', 'resvalue' => '140.823342734069', 'rescomment' => null],
['result_id' => 174, 'control_ref_id' => 5, 'test_ref_id' => 17, 'resdate' => '2022-01-05 00:00:00', 'resvalue' => '10.2', 'rescomment' => null],
['result_id' => 175, 'control_ref_id' => 6, 'test_ref_id' => 1, 'resdate' => '2022-01-05 00:00:00', 'resvalue' => '48.9587059015567', 'rescomment' => null],
['result_id' => 176, 'control_ref_id' => 6, 'test_ref_id' => 2, 'resdate' => '2022-01-05 00:00:00', 'resvalue' => '49.1468267441428', 'rescomment' => null],
['result_id' => 177, 'control_ref_id' => 6, 'test_ref_id' => 3, 'resdate' => '2022-01-05 00:00:00', 'resvalue' => '0.799690212662777', 'rescomment' => null],
['result_id' => 178, 'control_ref_id' => 6, 'test_ref_id' => 4, 'resdate' => '2022-01-05 00:00:00', 'resvalue' => '1.45552498470141', 'rescomment' => null],
['result_id' => 179, 'control_ref_id' => 6, 'test_ref_id' => 5, 'resdate' => '2022-01-05 00:00:00', 'resvalue' => '3.41160793396446', 'rescomment' => null],
['result_id' => 180, 'control_ref_id' => 6, 'test_ref_id' => 6, 'resdate' => '2022-01-05 00:00:00', 'resvalue' => '20.2910405834124', 'rescomment' => null],
['result_id' => 181, 'control_ref_id' => 6, 'test_ref_id' => 7, 'resdate' => '2022-01-05 00:00:00', 'resvalue' => '0.94094934133914', 'rescomment' => null],
['result_id' => 182, 'control_ref_id' => 6, 'test_ref_id' => 8, 'resdate' => '2022-01-05 00:00:00', 'resvalue' => '4.49152415745592', 'rescomment' => null],
['result_id' => 183, 'control_ref_id' => 6, 'test_ref_id' => 9, 'resdate' => '2022-01-05 00:00:00', 'resvalue' => '100.024475839182', 'rescomment' => null],
['result_id' => 184, 'control_ref_id' => 6, 'test_ref_id' => 10, 'resdate' => '2022-01-05 00:00:00', 'resvalue' => '85.9679935713317', 'rescomment' => null],
['result_id' => 185, 'control_ref_id' => 6, 'test_ref_id' => 11, 'resdate' => '2022-01-05 00:00:00', 'resvalue' => '53.8509856427683', 'rescomment' => null],
['result_id' => 186, 'control_ref_id' => 9, 'test_ref_id' => 1, 'resdate' => '2022-01-05 00:00:00', 'resvalue' => '42.7806264740846', 'rescomment' => null],
['result_id' => 187, 'control_ref_id' => 9, 'test_ref_id' => 2, 'resdate' => '2022-01-05 00:00:00', 'resvalue' => '51.9985050454933', 'rescomment' => null],
['result_id' => 188, 'control_ref_id' => 9, 'test_ref_id' => 3, 'resdate' => '2022-01-05 00:00:00', 'resvalue' => '0.649795363795779', 'rescomment' => null],
['result_id' => 189, 'control_ref_id' => 9, 'test_ref_id' => 4, 'resdate' => '2022-01-05 00:00:00', 'resvalue' => '1.80260045112525', 'rescomment' => null],
['result_id' => 190, 'control_ref_id' => 9, 'test_ref_id' => 5, 'resdate' => '2022-01-05 00:00:00', 'resvalue' => '3.35288773545917', 'rescomment' => null],
['result_id' => 191, 'control_ref_id' => 9, 'test_ref_id' => 6, 'resdate' => '2022-01-05 00:00:00', 'resvalue' => '20.6904621653494', 'rescomment' => null],
['result_id' => 192, 'control_ref_id' => 9, 'test_ref_id' => 7, 'resdate' => '2022-01-05 00:00:00', 'resvalue' => '1.19703451489628', 'rescomment' => null],
['result_id' => 193, 'control_ref_id' => 9, 'test_ref_id' => 8, 'resdate' => '2022-01-05 00:00:00', 'resvalue' => '4.89184138396658', 'rescomment' => null],
['result_id' => 194, 'control_ref_id' => 9, 'test_ref_id' => 9, 'resdate' => '2022-01-05 00:00:00', 'resvalue' => '91.9123811518993', 'rescomment' => null],
['result_id' => 195, 'control_ref_id' => 9, 'test_ref_id' => 10, 'resdate' => '2022-01-05 00:00:00', 'resvalue' => '100.544617296457', 'rescomment' => null],
['result_id' => 196, 'control_ref_id' => 9, 'test_ref_id' => 11, 'resdate' => '2022-01-05 00:00:00', 'resvalue' => '31.390065068111', 'rescomment' => null],
['result_id' => 197, 'control_ref_id' => 9, 'test_ref_id' => 12, 'resdate' => '2022-01-05 00:00:00', 'resvalue' => '4.17808071506795', 'rescomment' => null],
];
$this->db->table('results')->insertBatch($data);
}
}

0
app/Filters/.gitkeep Normal file
View File

0
app/Helpers/.gitkeep Normal file
View File

0
app/Language/.gitkeep Normal file
View File

View File

@ -0,0 +1,4 @@
<?php
// override core en language system validation or define your own en language validation message
return [];

0
app/Libraries/.gitkeep Normal file
View File

0
app/Models/.gitkeep Normal file
View File

View File

@ -0,0 +1,41 @@
<?php
namespace App\Models;
use CodeIgniter\Model;
class ControlModel extends Model
{
protected $table = 'dict_control';
protected $primaryKey = 'id';
protected $useAutoIncrement = true;
protected $returnType = 'array';
protected $useSoftDeletes = false;
protected $allowedFields = ['deptid', 'name', 'lot', 'producer', 'expdate'];
protected $useTimestamps = false;
public function getByDept($deptid)
{
return $this->where('deptid', $deptid)->findAll();
}
public function getWithDept()
{
$builder = $this->db->table('dict_control c');
$builder->select('c.*, d.name as dept_name');
$builder->join('dict_dept d', 'd.id = c.deptid', 'left');
return $builder->get()->getResultArray();
}
public function getActiveByDate($date, $deptid = null)
{
$builder = $this->db->table('dict_control c');
$builder->select('c.*');
$builder->where('c.expdate >=', $date);
if ($deptid) {
$builder->where('c.deptid', $deptid);
}
$builder->orderBy('c.name', 'ASC');
return $builder->get()->getResultArray();
}
}

View File

@ -0,0 +1,32 @@
<?php
namespace App\Models;
use CodeIgniter\Model;
class ControlTestModel extends Model
{
protected $table = 'control_tests';
protected $primaryKey = 'control_test_id';
protected $useAutoIncrement = true;
protected $returnType = 'array';
protected $useSoftDeletes = false;
protected $allowedFields = ['control_test_id', 'control_ref_id', 'test_ref_id', 'mean', 'sd'];
protected $useTimestamps = false;
public function getByControl($controlId)
{
$builder = $this->db->table('control_tests ct');
$builder->select('ct.*, t.name as test_name, t.unit');
$builder->join('dict_tests t', 't.test_id = ct.test_ref_id');
$builder->where('ct.control_ref_id', $controlId);
return $builder->get()->getResultArray();
}
public function getByControlAndTest($controlId, $testId)
{
return $this->where('control_ref_id', $controlId)
->where('test_ref_id', $testId)
->first();
}
}

View File

@ -0,0 +1,61 @@
<?php
namespace App\Models;
use CodeIgniter\Model;
class DailyResultModel extends Model
{
protected $table = 'daily_result';
protected $primaryKey = 'id';
protected $useAutoIncrement = true;
protected $returnType = 'array';
protected $useSoftDeletes = false;
protected $allowedFields = ['controlid', 'testid', 'resdate', 'resvalue', 'rescomment'];
protected $useTimestamps = false;
public function getByMonth($controlid, $testid, $yearMonth)
{
$startDate = $yearMonth . '-01';
$endDate = $yearMonth . '-31';
$builder = $this->db->table('daily_result');
$builder->select('*');
$builder->where('controlid', $controlid);
$builder->where('testid', $testid);
$builder->where('resdate >=', $startDate);
$builder->where('resdate <=', $endDate);
$builder->orderBy('resdate', 'ASC');
return $builder->get()->getResultArray();
}
public function getByControlMonth($controlid, $yearMonth)
{
$startDate = $yearMonth . '-01';
$endDate = $yearMonth . '-31';
$builder = $this->db->table('daily_result');
$builder->select('*');
$builder->where('controlid', $controlid);
$builder->where('resdate >=', $startDate);
$builder->where('resdate <=', $endDate);
return $builder->get()->getResultArray();
}
public function saveResult($data)
{
$builder = $this->db->table('daily_result');
$existing = $builder->select('*')
->where('controlid', $data['controlid'])
->where('testid', $data['testid'])
->where('resdate', $data['resdate'])
->get()
->getRowArray();
if ($existing) {
return $builder->where('id', $existing['id'])->update($data);
} else {
return $builder->insert($data);
}
}
}

16
app/Models/DeptModel.php Normal file
View File

@ -0,0 +1,16 @@
<?php
namespace App\Models;
use CodeIgniter\Model;
class DeptModel extends Model
{
protected $table = 'dict_dept';
protected $primaryKey = 'id';
protected $useAutoIncrement = true;
protected $returnType = 'array';
protected $useSoftDeletes = false;
protected $allowedFields = ['name'];
protected $useTimestamps = false;
}

View File

@ -0,0 +1,41 @@
<?php
namespace App\Models;
use CodeIgniter\Model;
class DictControlModel extends Model
{
protected $table = 'dict_controls';
protected $primaryKey = 'control_id';
protected $useAutoIncrement = true;
protected $returnType = 'array';
protected $useSoftDeletes = false;
protected $allowedFields = ['control_id', 'dept_ref_id', 'name', 'lot', 'producer', 'expdate'];
protected $useTimestamps = false;
public function getByDept($deptId)
{
return $this->where('dept_ref_id', $deptId)->findAll();
}
public function getWithDept()
{
$builder = $this->db->table('dict_controls c');
$builder->select('c.*, d.name as dept_name');
$builder->join('dict_depts d', 'd.dept_id = c.dept_ref_id', 'left');
return $builder->get()->getResultArray();
}
public function getActiveByDate($date, $deptId = null)
{
$builder = $this->db->table('dict_controls c');
$builder->select('c.*');
$builder->where('c.expdate >=', $date);
if ($deptId) {
$builder->where('c.dept_ref_id', $deptId);
}
$builder->orderBy('c.name', 'ASC');
return $builder->get()->getResultArray();
}
}

View File

@ -0,0 +1,16 @@
<?php
namespace App\Models;
use CodeIgniter\Model;
class DictDeptModel extends Model
{
protected $table = 'dict_depts';
protected $primaryKey = 'dept_id';
protected $useAutoIncrement = true;
protected $returnType = 'array';
protected $useSoftDeletes = false;
protected $allowedFields = ['dept_id', 'name'];
protected $useTimestamps = false;
}

View File

@ -0,0 +1,29 @@
<?php
namespace App\Models;
use CodeIgniter\Model;
class DictTestModel extends Model
{
protected $table = 'dict_tests';
protected $primaryKey = 'test_id';
protected $useAutoIncrement = true;
protected $returnType = 'array';
protected $useSoftDeletes = false;
protected $allowedFields = ['test_id', 'dept_ref_id', 'name', 'unit', 'method', 'cva', 'ba', 'tea'];
protected $useTimestamps = false;
public function getByDept($deptId)
{
return $this->where('dept_ref_id', $deptId)->findAll();
}
public function getWithDept()
{
$builder = $this->db->table('dict_tests t');
$builder->select('t.*, d.name as dept_name');
$builder->join('dict_depts d', 'd.dept_id = t.dept_ref_id', 'left');
return $builder->get()->getResultArray();
}
}

View File

@ -0,0 +1,38 @@
<?php
namespace App\Models;
use CodeIgniter\Model;
class MonthlyCommentModel extends Model
{
protected $table = 'monthly_comment';
protected $primaryKey = 'id';
protected $useAutoIncrement = true;
protected $returnType = 'array';
protected $useSoftDeletes = false;
protected $allowedFields = ['controlid', 'testid', 'commonth', 'comtext'];
protected $useTimestamps = false;
public function getByControlTestMonth($controlid, $testid, $yearMonth)
{
return $this->where('controlid', $controlid)
->where('testid', $testid)
->where('commonth', $yearMonth)
->first();
}
public function saveComment($data)
{
$existing = $this->where('controlid', $data['controlid'])
->where('testid', $data['testid'])
->where('commonth', $data['commonth'])
->first();
if ($existing) {
return $this->update($existing['id'], $data);
} else {
return $this->insert($data);
}
}
}

View File

@ -0,0 +1,38 @@
<?php
namespace App\Models;
use CodeIgniter\Model;
class ResultCommentModel extends Model
{
protected $table = 'result_comments';
protected $primaryKey = 'result_comment_id';
protected $useAutoIncrement = true;
protected $returnType = 'array';
protected $useSoftDeletes = false;
protected $allowedFields = ['result_comment_id', 'control_ref_id', 'test_ref_id', 'commonth', 'comtext'];
protected $useTimestamps = false;
public function getByControlTestMonth($controlId, $testId, $yearMonth)
{
return $this->where('control_ref_id', $controlId)
->where('test_ref_id', $testId)
->where('commonth', $yearMonth)
->first();
}
public function saveComment($data)
{
$existing = $this->where('control_ref_id', $data['control_ref_id'])
->where('test_ref_id', $data['test_ref_id'])
->where('commonth', $data['commonth'])
->first();
if ($existing) {
return $this->update($existing['result_comment_id'], $data);
} else {
return $this->insert($data);
}
}
}

View File

@ -0,0 +1,61 @@
<?php
namespace App\Models;
use CodeIgniter\Model;
class ResultModel extends Model
{
protected $table = 'results';
protected $primaryKey = 'result_id';
protected $useAutoIncrement = true;
protected $returnType = 'array';
protected $useSoftDeletes = false;
protected $allowedFields = ['result_id', 'control_ref_id', 'test_ref_id', 'resdate', 'resvalue', 'rescomment'];
protected $useTimestamps = false;
public function getByMonth($controlId, $testId, $yearMonth)
{
$startDate = $yearMonth . '-01';
$endDate = $yearMonth . '-31';
$builder = $this->db->table('results');
$builder->select('*');
$builder->where('control_ref_id', $controlId);
$builder->where('test_ref_id', $testId);
$builder->where('resdate >=', $startDate);
$builder->where('resdate <=', $endDate);
$builder->orderBy('resdate', 'ASC');
return $builder->get()->getResultArray();
}
public function getByControlMonth($controlId, $yearMonth)
{
$startDate = $yearMonth . '-01';
$endDate = $yearMonth . '-31';
$builder = $this->db->table('results');
$builder->select('*');
$builder->where('control_ref_id', $controlId);
$builder->where('resdate >=', $startDate);
$builder->where('resdate <=', $endDate);
return $builder->get()->getResultArray();
}
public function saveResult($data)
{
$builder = $this->db->table('results');
$existing = $builder->select('*')
->where('control_ref_id', $data['control_ref_id'])
->where('test_ref_id', $data['test_ref_id'])
->where('resdate', $data['resdate'])
->get()
->getRowArray();
if ($existing) {
return $builder->where('result_id', $existing['result_id'])->update($data);
} else {
return $builder->insert($data);
}
}
}

29
app/Models/TestModel.php Normal file
View File

@ -0,0 +1,29 @@
<?php
namespace App\Models;
use CodeIgniter\Model;
class TestModel extends Model
{
protected $table = 'dict_test';
protected $primaryKey = 'id';
protected $useAutoIncrement = true;
protected $returnType = 'array';
protected $useSoftDeletes = false;
protected $allowedFields = ['deptid', 'name', 'unit', 'method', 'cva', 'ba', 'tea'];
protected $useTimestamps = false;
public function getByDept($deptid)
{
return $this->where('deptid', $deptid)->findAll();
}
public function getWithDept()
{
$builder = $this->db->table('dict_test t');
$builder->select('t.*, d.name as dept_name');
$builder->join('dict_dept d', 'd.id = t.deptid', 'left');
return $builder->get()->getResultArray();
}
}

0
app/ThirdParty/.gitkeep vendored Normal file
View File

View File

@ -0,0 +1,95 @@
<!-- Backdrop -->
<div x-show="showModal"
x-transition:enter="transition ease-out duration-200"
x-transition:enter-start="opacity-0"
x-transition:enter-end="opacity-100"
x-transition:leave="transition ease-in duration-150"
x-transition:leave-start="opacity-100"
x-transition:leave-end="opacity-0"
class="fixed inset-0 bg-slate-900/50 backdrop-blur-sm z-40"
@click="closeModal()">
</div>
<!-- Modal Panel -->
<div x-show="showModal"
x-cloak
x-transition:enter="transition ease-out duration-200"
x-transition:enter-start="opacity-0 translate-y-4 sm:translate-y-0 sm:scale-95"
x-transition:enter-end="opacity-100 translate-y-0 sm:scale-100"
x-transition:leave="transition ease-in duration-150"
x-transition:leave-start="opacity-100 translate-y-0 sm:scale-100"
x-transition:leave-end="opacity-0 translate-y-4 sm:translate-y-0 sm:scale-95"
class="fixed inset-0 z-50 flex items-center justify-center p-4">
<div class="bg-white rounded-2xl shadow-2xl w-full max-w-2xl" @click.stop>
<!-- Header -->
<div class="px-6 py-4 border-b border-slate-100 flex items-center justify-between">
<h3 class="text-lg font-semibold text-slate-800" x-text="form.control_id ? 'Edit Control' : 'Add Control'"></h3>
<button @click="closeModal()" class="text-slate-400 hover:text-slate-600">
<i class="fa-solid fa-xmark text-xl"></i>
</button>
</div>
<!-- Form -->
<form @submit.prevent="save()">
<div class="p-6">
<div class="grid grid-cols-2 gap-4">
<div>
<label class="block text-sm font-medium text-slate-700 mb-1">Department <span class="text-red-500">*</span></label>
<select x-model="form.dept_ref_id" class="w-full px-4 py-2.5 text-sm bg-slate-50 border border-slate-200 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500/20 focus:border-blue-500" :class="{'border-red-300 bg-red-50': errors.dept_ref_id}" required>
<option value="">Select Department</option>
<template x-for="dept in depts" :key="dept.dept_id">
<option :value="dept.dept_id" x-text="dept.name"></option>
</template>
</select>
<p x-show="errors.dept_ref_id" x-text="errors.dept_ref_id" class="text-red-500 text-xs mt-1"></p>
</div>
<div>
<label class="block text-sm font-medium text-slate-700 mb-1">Control Name <span class="text-red-500">*</span></label>
<input type="text" x-model="form.name" class="w-full px-4 py-2.5 text-sm bg-slate-50 border border-slate-200 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500/20 focus:border-blue-500" :class="{'border-red-300 bg-red-50': errors.name}" placeholder="Enter control name" required>
<p x-show="errors.name" x-text="errors.name" class="text-red-500 text-xs mt-1"></p>
</div>
<div>
<label class="block text-sm font-medium text-slate-700 mb-1">Lot Number</label>
<input type="text" x-model="form.lot" class="w-full px-4 py-2.5 text-sm bg-slate-50 border border-slate-200 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500/20 focus:border-blue-500" placeholder="Enter lot number">
</div>
<div>
<label class="block text-sm font-medium text-slate-700 mb-1">Producer</label>
<input type="text" x-model="form.producer" class="w-full px-4 py-2.5 text-sm bg-slate-50 border border-slate-200 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500/20 focus:border-blue-500" placeholder="Enter producer">
</div>
<div class="col-span-2">
<label class="block text-sm font-medium text-slate-700 mb-1">Expiry Date</label>
<input type="date" x-model="form.expdate" class="w-full px-4 py-2.5 text-sm bg-slate-50 border border-slate-200 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500/20 focus:border-blue-500">
</div>
<div class="col-span-2">
<label class="block text-sm font-medium text-slate-700 mb-1">Assigned Tests</label>
<div class="border border-slate-200 rounded-lg p-3 bg-slate-50 max-h-48 overflow-y-auto">
<div class="grid grid-cols-2 gap-2">
<template x-for="test in tests" :key="test.test_id">
<label class="flex items-center gap-2 cursor-pointer">
<input type="checkbox" :value="test.test_id" x-model="form.test_ids" class="w-4 h-4 text-blue-600 rounded border-slate-300 focus:ring-blue-500">
<span class="text-sm text-slate-700" x-text="test.name + ' (' + (test.dept_name || '') + ')'"></span>
</label>
</template>
</div>
</div>
<p class="text-xs text-slate-500 mt-1">Select tests to associate with this control</p>
</div>
</div>
</div>
<!-- Footer -->
<div class="flex items-center justify-end gap-3 px-6 py-4 border-t border-slate-100 bg-slate-50/50 rounded-b-2xl">
<button type="button" @click="closeModal()" class="px-4 py-2 text-sm font-medium text-slate-600 hover:text-slate-800 transition-colors">Cancel</button>
<button type="submit" :disabled="loading" class="px-4 py-2 text-sm font-medium text-white bg-blue-600 rounded-lg hover:bg-blue-700 disabled:opacity-50 disabled:cursor-not-allowed transition-colors">
<template x-if="!loading">
<span><i class="fa-solid fa-check mr-1"></i> <span x-text="form.control_id ? 'Update' : 'Save'"></span></span>
</template>
<template x-if="loading">
<span><i class="fa-solid fa-spinner fa-spin mr-1"></i> Saving...</span>
</template>
</button>
</div>
</form>
</div>
</div>

View File

@ -0,0 +1,46 @@
<div class="max-w-2xl mx-auto">
<div class="bg-white rounded-lg shadow p-6">
<h2 class="text-2xl font-bold text-gray-800 mb-6"><?= isset($control) ? 'Edit Control' : 'Add New Control' ?></h2>
<form action="<?= isset($control) ? base_url('/control/update/' . $control['control_id']) : base_url('/control/save') ?>" method="post">
<div class="space-y-4">
<div>
<label class="block text-sm font-medium text-gray-700 mb-1">Department</label>
<select name="deptid" class="w-full border border-gray-300 rounded-lg px-4 py-2 focus:ring-2 focus:ring-primary-500 focus:border-primary-500">
<option value="">Select Department</option>
<?php foreach ($depts as $dept): ?>
<option value="<?= $dept['dept_id'] ?>" <?= (isset($control) && $control['dept_ref_id'] == $dept['dept_id']) ? 'selected' : '' ?>>
<?= $dept['name'] ?>
</option>
<?php endforeach; ?>
</select>
</div>
<div>
<label class="block text-sm font-medium text-gray-700 mb-1">Control Name</label>
<input type="text" name="name" value="<?= $control['name'] ?? '' ?>" class="w-full border border-gray-300 rounded-lg px-4 py-2 focus:ring-2 focus:ring-primary-500 focus:border-primary-500" required>
</div>
<div>
<label class="block text-sm font-medium text-gray-700 mb-1">Lot Number</label>
<input type="text" name="lot" value="<?= $control['lot'] ?? '' ?>" class="w-full border border-gray-300 rounded-lg px-4 py-2 focus:ring-2 focus:ring-primary-500 focus:border-primary-500">
</div>
<div>
<label class="block text-sm font-medium text-gray-700 mb-1">Expiry Date</label>
<input type="date" name="expdate" value="<?= $control['expdate'] ?? '' ?>" class="w-full border border-gray-300 rounded-lg px-4 py-2 focus:ring-2 focus:ring-primary-500 focus:border-primary-500">
</div>
<div>
<label class="block text-sm font-medium text-gray-700 mb-1">Producer</label>
<textarea name="producer" rows="3" class="w-full border border-gray-300 rounded-lg px-4 py-2 focus:ring-2 focus:ring-primary-500 focus:border-primary-500"><?= $control['producer'] ?? '' ?></textarea>
</div>
<div class="flex justify-end space-x-4 pt-4">
<a href="<?= base_url('/control') ?>" class="bg-gray-300 hover:bg-gray-400 text-gray-800 px-4 py-2 rounded-lg">Cancel</a>
<button type="submit" class="bg-primary-600 hover:bg-primary-700 text-white px-4 py-2 rounded-lg">Save</button>
</div>
</div>
</form>
</div>
</div>

242
app/Views/control/index.php Normal file
View File

@ -0,0 +1,242 @@
<?= $this->extend("layout/main_layout"); ?>
<?= $this->section("content") ?>
<main x-data="controlIndex()">
<!-- Page Header -->
<div class="flex items-center justify-between mb-6">
<div>
<h1 class="text-2xl font-bold text-slate-800">Control Dictionary</h1>
<p class="text-sm text-slate-500 mt-1">Manage control materials and lot numbers</p>
</div>
<button @click="showForm()" class="btn btn-primary">
<i class="fa-solid fa-plus mr-2"></i>Add Control
</button>
</div>
<!-- Error Alert -->
<div x-show="error" x-transition class="bg-red-50 border border-red-200 text-red-700 px-4 py-3 rounded-lg mb-6">
<div class="flex items-center gap-2">
<i class="fa-solid fa-circle-exclamation"></i>
<span x-text="error"></span>
</div>
</div>
<!-- Search Card -->
<div class="bg-white rounded-xl border border-slate-100 shadow-sm p-4 mb-6">
<div class="flex gap-3">
<div class="flex-1 relative">
<i class="fa-solid fa-magnifying-glass absolute left-3 top-1/2 -translate-y-1/2 text-slate-400"></i>
<input type="text" x-model="keyword" @keyup.enter="fetchList()" class="w-full pl-10 pr-4 py-2.5 text-sm bg-slate-50 border border-slate-200 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500/20 focus:border-blue-500" placeholder="Search controls...">
</div>
<button @click="fetchList()" class="btn btn-primary">
<i class="fa-solid fa-magnifying-glass mr-2"></i>Search
</button>
</div>
</div>
<!-- Data Table Card -->
<div class="bg-white rounded-xl border border-slate-100 shadow-sm overflow-hidden">
<!-- Loading State -->
<template x-if="loading">
<div class="p-12 text-center">
<div class="w-16 h-16 rounded-full bg-blue-50 flex items-center justify-center mx-auto mb-4">
<i class="fa-solid fa-spinner fa-spin text-blue-500 text-xl"></i>
</div>
<p class="text-slate-500 text-sm">Loading controls...</p>
</div>
</template>
<!-- Empty State -->
<template x-if="!loading && (!list || list.length === 0)">
<div class="flex-1 flex items-center justify-center p-8">
<div class="text-center">
<div class="w-12 h-12 rounded-full bg-slate-100 flex items-center justify-center mx-auto mb-3">
<i class="fa-solid fa-sliders text-slate-400 text-xl"></i>
</div>
<p class="text-slate-500 text-sm">No controls found</p>
</div>
</div>
</template>
<!-- Data Table -->
<template x-if="!loading && list && list.length > 0">
<table class="w-full text-sm text-left">
<thead class="bg-slate-50 text-slate-500 text-xs uppercase tracking-wider">
<tr>
<th class="py-3 px-5 font-semibold">#</th>
<th class="py-3 px-5 font-semibold">Name</th>
<th class="py-3 px-5 font-semibold">Lot</th>
<th class="py-3 px-5 font-semibold">Department</th>
<th class="py-3 px-5 font-semibold">Expiry Date</th>
<th class="py-3 px-5 font-semibold text-right">Actions</th>
</tr>
</thead>
<tbody class="divide-y divide-slate-100">
<template x-for="(item, index) in list" :key="item.control_id">
<tr class="hover:bg-slate-50/50 transition-colors">
<td class="py-3 px-5" x-text="index + 1"></td>
<td class="py-3 px-5 font-medium text-slate-800" x-text="item.name"></td>
<td class="py-3 px-5 text-slate-600">
<span class="font-mono text-xs bg-slate-100 text-slate-600 px-2 py-1 rounded" x-text="item.lot || '-'"></span>
</td>
<td class="py-3 px-5 text-slate-600" x-text="item.dept_name || '-'"></td>
<td class="py-3 px-5 text-slate-600" x-text="item.expdate ? new Date(item.expdate).toLocaleDateString() : '-'"></td>
<td class="py-3 px-5 text-right">
<button @click="showForm(item.control_id)" class="text-blue-600 hover:text-blue-800 mr-3">
<i class="fa-solid fa-pen-to-square"></i>
</button>
<button @click="deleteItem(item.control_id)" class="text-red-600 hover:text-red-800">
<i class="fa-solid fa-trash"></i>
</button>
</td>
</tr>
</template>
</tbody>
</table>
</template>
</div>
<!-- Dialog Include -->
<?= $this->include('control/dialog_form'); ?>
</main>
<?= $this->endSection(); ?>
<?= $this->section("script") ?>
<script>
document.addEventListener('alpine:init', () => {
Alpine.data("controlIndex", () => ({
loading: false,
showModal: false,
list: [],
form: {},
errors: {},
error: '',
keyword: '',
depts: <?= json_encode($depts ?? []) ?>,
tests: <?= json_encode($tests ?? []) ?>,
init() {
this.fetchList();
},
async fetchList() {
this.loading = true;
this.error = '';
try {
const res = await fetch(`${window.BASEURL}/api/control`);
const data = await res.json();
if (data.status === 'success') {
this.list = data.data || [];
} else {
this.error = data.message || 'Failed to load controls';
}
} catch (err) {
console.error(err);
this.error = 'Network error. Please try again.';
} finally {
this.loading = false;
}
},
async showForm(id = null) {
this.errors = {};
if (id) {
const item = this.list.find(x => x.control_id === id);
if (item) {
this.form = {
control_id: item.control_id,
dept_ref_id: item.dept_ref_id,
name: item.name,
lot: item.lot || '',
producer: item.producer || '',
expdate: item.expdate || '',
test_ids: []
};
// Fetch assigned tests
try {
const res = await fetch(`${window.BASEURL}/api/control/${id}/tests`);
const data = await res.json();
if (data.status === 'success') {
this.form.test_ids = data.data || [];
}
} catch (err) {
console.error('Failed to fetch assigned tests', err);
}
}
} else {
this.form = {
dept_ref_id: '',
name: '',
lot: '',
producer: '',
expdate: '',
test_ids: []
};
}
this.showModal = true;
},
closeModal() {
this.showModal = false;
this.errors = {};
this.form = {};
},
validate() {
this.errors = {};
if (!this.form.dept_ref_id) this.errors.dept_ref_id = 'Department is required';
if (!this.form.name) this.errors.name = 'Control name is required';
return Object.keys(this.errors).length === 0;
},
async save() {
if (!this.validate()) return;
this.loading = true;
try {
const url = this.form.control_id
? `${window.BASEURL}/api/control/${this.form.control_id}`
: `${window.BASEURL}/api/control`;
const res = await fetch(url, {
method: this.form.control_id ? 'PUT' : 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(this.form)
});
const data = await res.json();
if (data.status === 'success') {
this.closeModal();
this.fetchList();
} else {
this.error = data.message || 'Failed to save control';
}
} catch (err) {
console.error(err);
this.error = 'Network error. Please try again.';
} finally {
this.loading = false;
}
},
async deleteItem(id) {
if (!confirm('Are you sure you want to delete this control?')) return;
this.loading = true;
try {
const res = await fetch(`${window.BASEURL}/api/control/${id}`, { method: 'DELETE' });
const data = await res.json();
if (data.status === 'success') {
this.fetchList();
} else {
this.error = data.message || 'Failed to delete control';
}
} catch (err) {
console.error(err);
this.error = 'Network error. Please try again.';
} finally {
this.loading = false;
}
}
}));
});
</script>
<?= $this->endSection(); ?>

142
app/Views/dashboard.php Normal file
View File

@ -0,0 +1,142 @@
<?= $this->extend("layout/main_layout"); ?>
<?= $this->section("content") ?>
<main x-data="dashboard()">
<div class="space-y-8">
<div class="grid grid-cols-1 md:grid-cols-3 gap-6">
<div class="bg-white rounded-2xl p-6 shadow-sm border border-slate-100 hover:shadow-md transition-shadow duration-200 group">
<div class="flex items-center justify-between">
<div>
<p class="text-sm font-medium text-slate-500 mb-1">Total Tests</p>
<h3 class="text-3xl font-bold text-slate-800 group-hover:text-primary-600 transition-colors"><?= count($tests) ?></h3>
</div>
<div class="h-12 w-12 rounded-xl bg-blue-50 text-blue-600 flex items-center justify-center group-hover:scale-110 transition-transform duration-200">
<i class="fa-solid fa-file-medical text-2xl"></i>
</div>
</div>
<div class="mt-4 flex items-center text-sm text-slate-500">
<span class="text-green-600 font-medium flex items-center mr-2">
<i class="fa-solid fa-check-circle mr-1"></i>
Active
</span>
<span>in library</span>
</div>
</div>
<div class="bg-white rounded-2xl p-6 shadow-sm border border-slate-100 hover:shadow-md transition-shadow duration-200 group">
<div class="flex items-center justify-between">
<div>
<p class="text-sm font-medium text-slate-500 mb-1">Total Controls</p>
<h3 class="text-3xl font-bold text-slate-800 group-hover:text-primary-600 transition-colors"><?= count($controls) ?></h3>
</div>
<div class="h-12 w-12 rounded-xl bg-emerald-50 text-emerald-600 flex items-center justify-center group-hover:scale-110 transition-transform duration-200">
<i class="fa-solid fa-vial text-2xl"></i>
</div>
</div>
<div class="mt-4 flex items-center text-sm text-slate-500">
<span class="text-slate-600 font-medium flex items-center mr-2">Reference</span>
<span>definitions</span>
</div>
</div>
<div class="bg-white rounded-2xl p-6 shadow-sm border border-slate-100 hover:shadow-md transition-shadow duration-200 group">
<div class="flex items-center justify-between">
<div>
<p class="text-sm font-medium text-slate-500 mb-1">Departments</p>
<h3 class="text-3xl font-bold text-slate-800 group-hover:text-primary-600 transition-colors"><?= count($depts) ?></h3>
</div>
<div class="h-12 w-12 rounded-xl bg-violet-50 text-violet-600 flex items-center justify-center group-hover:scale-110 transition-transform duration-200">
<i class="fa-solid fa-building text-2xl"></i>
</div>
</div>
<div class="mt-4 flex items-center text-sm text-slate-500">
<span class="text-slate-600 font-medium flex items-center mr-2">Active</span>
<span>units</span>
</div>
</div>
</div>
<div class="bg-white rounded-2xl shadow-sm border border-slate-100 overflow-hidden">
<div class="px-6 py-5 border-b border-slate-100 bg-white">
<h3 class="text-lg font-bold text-slate-800">Menu</h3>
<p class="text-sm text-slate-500">Quick access to all features</p>
</div>
<div class="p-6">
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4">
<a href="<?= base_url('/test') ?>" class="flex items-start p-4 rounded-xl border border-slate-200 hover:border-primary-300 hover:bg-primary-50/50 transition-all duration-200 group">
<div class="h-10 w-10 rounded-lg bg-blue-100 text-blue-600 flex items-center justify-center mr-4 group-hover:scale-110 transition-transform">
<i class="fa-solid fa-vial"></i>
</div>
<div>
<h4 class="font-semibold text-slate-800 group-hover:text-primary-600">Test Definitions</h4>
<p class="text-sm text-slate-500 mt-1">Manage test types, methods, and units</p>
</div>
</a>
<a href="<?= base_url('/control') ?>" class="flex items-start p-4 rounded-xl border border-slate-200 hover:border-primary-300 hover:bg-primary-50/50 transition-all duration-200 group">
<div class="h-10 w-10 rounded-lg bg-emerald-100 text-emerald-600 flex items-center justify-center mr-4 group-hover:scale-110 transition-transform">
<i class="fa-solid fa-sliders"></i>
</div>
<div>
<h4 class="font-semibold text-slate-800 group-hover:text-primary-600">Control Dictionary</h4>
<p class="text-sm text-slate-500 mt-1">Manage control materials and lot numbers</p>
</div>
</a>
<a href="<?= base_url('/dept') ?>" class="flex items-start p-4 rounded-xl border border-slate-200 hover:border-primary-300 hover:bg-primary-50/50 transition-all duration-200 group">
<div class="h-10 w-10 rounded-lg bg-violet-100 text-violet-600 flex items-center justify-center mr-4 group-hover:scale-110 transition-transform">
<i class="fa-solid fa-building"></i>
</div>
<div>
<h4 class="font-semibold text-slate-800 group-hover:text-primary-600">Department Dictionary</h4>
<p class="text-sm text-slate-500 mt-1">Manage departments and units</p>
</div>
</a>
<a href="<?= base_url('/entry') ?>" class="flex items-start p-4 rounded-xl border border-slate-200 hover:border-primary-300 hover:bg-primary-50/50 transition-all duration-200 group">
<div class="h-10 w-10 rounded-lg bg-amber-100 text-amber-600 flex items-center justify-center mr-4 group-hover:scale-110 transition-transform">
<i class="fa-solid fa-calendar-check"></i>
</div>
<div>
<h4 class="font-semibold text-slate-800 group-hover:text-primary-600">Monthly Entry</h4>
<p class="text-sm text-slate-500 mt-1">Enter monthly QC results</p>
</div>
</a>
<a href="<?= base_url('/entry/daily') ?>" class="flex items-start p-4 rounded-xl border border-slate-200 hover:border-primary-300 hover:bg-primary-50/50 transition-all duration-200 group">
<div class="h-10 w-10 rounded-lg bg-rose-100 text-rose-600 flex items-center justify-center mr-4 group-hover:scale-110 transition-transform">
<i class="fa-solid fa-calendar-day"></i>
</div>
<div>
<h4 class="font-semibold text-slate-800 group-hover:text-primary-600">Daily Entry</h4>
<p class="text-sm text-slate-500 mt-1">Enter daily QC results</p>
</div>
</a>
<a href="<?= base_url('/report') ?>" class="flex items-start p-4 rounded-xl border border-slate-200 hover:border-primary-300 hover:bg-primary-50/50 transition-all duration-200 group">
<div class="h-10 w-10 rounded-lg bg-indigo-100 text-indigo-600 flex items-center justify-center mr-4 group-hover:scale-110 transition-transform">
<i class="fa-solid fa-chart-column"></i>
</div>
<div>
<h4 class="font-semibold text-slate-800 group-hover:text-primary-600">Reports</h4>
<p class="text-sm text-slate-500 mt-1">View and generate QC reports</p>
</div>
</a>
</div>
</div>
</div>
</div>
</main>
<?= $this->endSection(); ?>
<?= $this->section("script") ?>
<script>
document.addEventListener('alpine:init', () => {
Alpine.data("dashboard", () => ({
init() {
// Dashboard init
}
}));
});
</script>
<?= $this->endSection(); ?>

View File

@ -0,0 +1,60 @@
<!-- Backdrop -->
<div x-show="showModal"
x-transition:enter="transition ease-out duration-200"
x-transition:enter-start="opacity-0"
x-transition:enter-end="opacity-100"
x-transition:leave="transition ease-in duration-150"
x-transition:leave-start="opacity-100"
x-transition:leave-end="opacity-0"
class="fixed inset-0 bg-slate-900/50 backdrop-blur-sm z-40"
@click="closeModal()">
</div>
<!-- Modal Panel -->
<div x-show="showModal"
x-cloak
x-transition:enter="transition ease-out duration-200"
x-transition:enter-start="opacity-0 translate-y-4 sm:translate-y-0 sm:scale-95"
x-transition:enter-end="opacity-100 translate-y-0 sm:scale-100"
x-transition:leave="transition ease-in duration-150"
x-transition:leave-start="opacity-100 translate-y-0 sm:scale-100"
x-transition:leave-end="opacity-0 translate-y-4 sm:translate-y-0 sm:scale-95"
class="fixed inset-0 z-50 flex items-center justify-center p-4">
<div class="relative bg-white rounded-2xl shadow-2xl w-full max-w-md" @click.stop>
<!-- Header -->
<div class="px-6 py-4 border-b border-slate-100 flex items-center justify-between">
<h3 class="text-lg font-semibold text-slate-800" x-text="form.dept_id ? 'Edit Department' : 'Add Department'"></h3>
<button @click="closeModal()" class="text-slate-400 hover:text-slate-600">
<i class="fa-solid fa-xmark text-xl"></i>
</button>
</div>
<!-- Form -->
<form @submit.prevent="save()">
<div class="p-6">
<div>
<label class="block text-sm font-medium text-slate-700 mb-1">Department Name <span class="text-red-500">*</span></label>
<input type="text" x-model="form.name"
class="w-full px-4 py-2.5 text-sm bg-slate-50 border border-slate-200 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500/20 focus:border-blue-500 transition-all"
:class="{'border-red-300 bg-red-50': errors.name}"
placeholder="Enter department name" required>
<p x-show="errors.name" x-text="errors.name" class="text-red-500 text-xs mt-1"></p>
</div>
</div>
<!-- Footer -->
<div class="flex items-center justify-end gap-3 px-6 py-4 border-t border-slate-100 bg-slate-50/50 rounded-b-2xl">
<button type="button" @click="closeModal()" class="px-4 py-2 text-sm font-medium text-slate-600 hover:text-slate-800 transition-colors">Cancel</button>
<button type="submit" :disabled="loading" class="px-4 py-2 text-sm font-medium text-white bg-blue-600 rounded-lg hover:bg-blue-700 disabled:opacity-50 disabled:cursor-not-allowed transition-colors">
<template x-if="!loading">
<span><i class="fa-solid fa-check mr-1"></i> <span x-text="form.dept_id ? 'Update' : 'Save'"></span></span>
</template>
<template x-if="loading">
<span><i class="fa-solid fa-spinner fa-spin mr-1"></i> Saving...</span>
</template>
</button>
</div>
</form>
</div>
</div>

187
app/Views/dept/index.php Normal file
View File

@ -0,0 +1,187 @@
<?= $this->extend("layout/main_layout"); ?>
<?= $this->section("content") ?>
<main x-data="deptIndex()">
<!-- Page Header -->
<div class="flex items-center justify-between mb-6">
<div>
<h1 class="text-2xl font-bold text-slate-800">Department Dictionary</h1>
<p class="text-sm text-slate-500 mt-1">Manage department entries</p>
</div>
<button @click="showForm()" class="btn btn-primary">
<i class="fa-solid fa-plus mr-2"></i>Add Department
</button>
</div>
<!-- Error Alert -->
<div x-show="error" x-transition class="bg-red-50 border border-red-200 text-red-700 px-4 py-3 rounded-lg mb-6">
<div class="flex items-center gap-2">
<i class="fa-solid fa-circle-exclamation"></i>
<span x-text="error"></span>
</div>
</div>
<!-- Data Table Card -->
<div class="bg-white rounded-xl border border-slate-100 shadow-sm overflow-hidden">
<!-- Loading State -->
<template x-if="loading">
<div class="p-12 text-center">
<div class="w-16 h-16 rounded-full bg-blue-50 flex items-center justify-center mx-auto mb-4">
<i class="fa-solid fa-spinner fa-spin text-blue-500 text-xl"></i>
</div>
<p class="text-slate-500 text-sm">Loading departments...</p>
</div>
</template>
<!-- Empty State -->
<template x-if="!loading && (!list || list.length === 0)">
<div class="flex-1 flex items-center justify-center p-8">
<div class="text-center">
<div class="w-12 h-12 rounded-full bg-slate-100 flex items-center justify-center mx-auto mb-3">
<i class="fa-solid fa-inbox text-slate-400"></i>
</div>
<p class="text-slate-500 text-sm">No departments found</p>
</div>
</div>
</template>
<!-- Data Table -->
<template x-if="!loading && list && list.length > 0">
<table class="w-full text-sm text-left">
<thead class="bg-slate-50 text-slate-500 text-xs uppercase tracking-wider">
<tr>
<th class="py-3 px-5 font-semibold">#</th>
<th class="py-3 px-5 font-semibold">Name</th>
<th class="py-3 px-5 font-semibold text-right">Actions</th>
</tr>
</thead>
<tbody class="divide-y divide-slate-100">
<template x-for="(item, index) in list" :key="item.dept_id">
<tr class="hover:bg-slate-50/50 transition-colors">
<td class="py-3 px-5" x-text="index + 1"></td>
<td class="py-3 px-5 font-medium text-slate-800" x-text="item.name"></td>
<td class="py-3 px-5 text-right">
<button @click="showForm(item.dept_id)" class="text-blue-600 hover:text-blue-800 mr-3">
<i class="fa-solid fa-pen-to-square"></i>
</button>
<button @click="deleteItem(item.dept_id)" class="text-red-600 hover:text-red-800">
<i class="fa-solid fa-trash"></i>
</button>
</td>
</tr>
</template>
</tbody>
</table>
</template>
</div>
<!-- Dialog Include -->
<?= $this->include('dept/dialog_form'); ?>
</main>
<?= $this->endSection(); ?>
<?= $this->section("script") ?>
<script>
document.addEventListener('alpine:init', () => {
Alpine.data("deptIndex", () => ({
loading: false,
showModal: false,
list: [],
form: {},
errors: {},
error: '',
init() {
this.fetchList();
},
async fetchList() {
this.loading = true;
this.error = '';
try {
const res = await fetch(`${window.BASEURL}/api/dept`);
const data = await res.json();
if (data.status === 'success') {
this.list = data.data || [];
} else {
this.error = data.message || 'Failed to load departments';
}
} catch (err) {
console.error(err);
this.error = 'Network error. Please try again.';
} finally {
this.loading = false;
}
},
showForm(id = null) {
this.form = id ? JSON.parse(JSON.stringify(this.list.find(x => x.dept_id === id))) : {};
this.errors = {};
this.showModal = true;
},
closeModal() {
this.showModal = false;
this.errors = {};
this.form = {};
},
validate() {
this.errors = {};
if (!this.form.name) {
this.errors.name = 'Department name is required';
}
return Object.keys(this.errors).length === 0;
},
async save() {
if (!this.validate()) return;
this.loading = true;
try {
const url = this.form.dept_id
? `${window.BASEURL}/api/dept/${this.form.dept_id}`
: `${window.BASEURL}/api/dept`;
const res = await fetch(url, {
method: this.form.dept_id ? 'PUT' : 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ name: this.form.name })
});
const data = await res.json();
if (data.status === 'success') {
this.closeModal();
this.fetchList();
} else {
this.error = data.message || 'Failed to save department';
}
} catch (err) {
console.error(err);
this.error = 'Network error. Please try again.';
} finally {
this.loading = false;
}
},
async deleteItem(id) {
if (!confirm('Are you sure you want to delete this department?')) return;
this.loading = true;
try {
const res = await fetch(`${window.BASEURL}/api/dept/${id}`, { method: 'DELETE' });
const data = await res.json();
if (data.status === 'success') {
this.fetchList();
} else {
this.error = data.message || 'Failed to delete department';
}
} catch (err) {
console.error(err);
this.error = 'Network error. Please try again.';
} finally {
this.loading = false;
}
}
}));
});
</script>
<?= $this->endSection(); ?>

256
app/Views/entry/daily.php Normal file
View File

@ -0,0 +1,256 @@
<?= $this->extend("layout/main_layout"); ?>
<?= $this->section("content") ?>
<main x-data="dailyEntry()">
<div class="bg-white rounded-xl border border-slate-100 shadow-sm p-6">
<div class="flex items-center justify-between mb-6">
<div>
<h1 class="text-2xl font-bold text-slate-800">Daily Entry</h1>
<p class="text-sm text-slate-500 mt-1">Enter daily QC results</p>
</div>
<div class="flex items-center gap-2 text-sm text-slate-500">
<i class="fa-solid fa-clock"></i>
<span>Press Ctrl+S to save</span>
</div>
</div>
<div x-show="error" x-transition class="bg-red-50 border border-red-200 text-red-700 px-4 py-3 rounded-lg mb-6">
<div class="flex items-center gap-2">
<i class="fa-solid fa-circle-exclamation"></i>
<span x-text="error"></span>
</div>
</div>
<div class="grid grid-cols-1 md:grid-cols-4 gap-4">
<div>
<label class="block text-sm font-medium text-slate-700 mb-1">Department <span class="text-red-500">*</span></label>
<select x-model="dept" @change="loadControls()" :class="errors.dept ? 'border-red-300 bg-red-50' : ''" class="w-full px-4 py-2.5 text-sm bg-slate-50 border border-slate-200 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500/20 focus:border-blue-500">
<option value="">Select Department</option>
<?php foreach ($depts as $d): ?>
<option value="<?= $d['dept_id'] ?>"><?= $d['name'] ?></option>
<?php endforeach; ?>
</select>
<p x-show="errors.dept" x-text="errors.dept" class="text-red-500 text-xs mt-1"></p>
</div>
<div>
<label class="block text-sm font-medium text-slate-700 mb-1">Date <span class="text-red-500">*</span></label>
<input type="date" x-model="date" :class="errors.date ? 'border-red-300 bg-red-50' : ''" class="w-full px-4 py-2.5 text-sm bg-slate-50 border border-slate-200 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500/20 focus:border-blue-500">
<p x-show="errors.date" x-text="errors.date" class="text-red-500 text-xs mt-1"></p>
</div>
<div>
<label class="block text-sm font-medium text-slate-700 mb-1">Control <span class="text-red-500">*</span></label>
<select x-model="control" @change="loadTests()" :class="errors.control ? 'border-red-300 bg-red-50' : ''" class="w-full px-4 py-2.5 text-sm bg-slate-50 border border-slate-200 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500/20 focus:border-blue-500">
<option value="">Select Control</option>
<template x-for="c in controls" :key="c.control_id">
<option :value="c.control_id" x-text="c.name + ' (' + (c.lot || 'N/A') + ')'"></option>
</template>
</select>
<p x-show="errors.control" x-text="errors.control" class="text-red-500 text-xs mt-1"></p>
</div>
<div>
<label class="block text-sm font-medium text-slate-700 mb-1">Test <span class="text-red-500">*</span></label>
<select x-model="test" :class="errors.test ? 'border-red-300 bg-red-50' : ''" class="w-full px-4 py-2.5 text-sm bg-slate-50 border border-slate-200 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500/20 focus:border-blue-500">
<option value="">Select Test</option>
<template x-for="t in tests" :key="t.test_ref_id">
<option :value="t.test_ref_id" x-text="t.test_name"></option>
</template>
</select>
<p x-show="errors.test" x-text="errors.test" class="text-red-500 text-xs mt-1"></p>
</div>
</div>
<div class="mt-6" x-show="control && test" x-transition>
<div class="bg-white rounded-xl border border-slate-100 shadow-sm p-6">
<h3 class="text-lg font-semibold text-slate-800 mb-4">Result</h3>
<div class="grid grid-cols-1 md:grid-cols-2 gap-4">
<div>
<label class="block text-sm font-medium text-slate-700 mb-1">Value <span class="text-red-500">*</span></label>
<input type="number" step="0.01" x-model="resvalue" :class="errors.resvalue ? 'border-red-300 bg-red-50' : ''" class="w-full px-4 py-2.5 text-sm bg-slate-50 border border-slate-200 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500/20 focus:border-blue-500" placeholder="Enter value">
<p x-show="errors.resvalue" x-text="errors.resvalue" class="text-red-500 text-xs mt-1"></p>
</div>
<div>
<label class="block text-sm font-medium text-slate-700 mb-1">Comment</label>
<input type="text" x-model="rescomment" class="w-full px-4 py-2.5 text-sm bg-slate-50 border border-slate-200 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500/20 focus:border-blue-500" placeholder="Optional comment">
</div>
</div>
<div class="mt-4">
<button @click="saveResult()" data-save-btn :disabled="loading" class="btn btn-primary">
<template x-if="!loading">
<span class="flex items-center">
<i class="fa-solid fa-check mr-2"></i>
Save Result
</span>
</template>
<template x-if="loading">
<span class="flex items-center">
<i class="fa-solid fa-spinner fa-spin mr-2"></i>
Saving...
</span>
</template>
</button>
</div>
</div>
</div>
</div>
</main>
<?= $this->endSection(); ?>
<?= $this->section("script") ?>
<script>
document.addEventListener('alpine:init', () => {
Alpine.data("dailyEntry", () => ({
dept: '',
date: new Date().toISOString().split('T')[0],
control: '',
test: '',
resvalue: '',
rescomment: '',
controls: [],
tests: [],
loading: false,
errors: {},
error: '',
init() {
this.loadDraft();
},
async loadControls() {
this.errors = {};
this.controls = [];
this.control = '';
this.tests = [];
this.test = '';
if (!this.dept || !this.date) {
return;
}
this.loading = true;
try {
const response = await fetch(`${window.BASEURL}/api/entry/controls?date=${this.date}&deptid=${this.dept}`);
const data = await response.json();
if (data.status === 'success') {
this.controls = data.data || [];
if (this.controls.length === 0) {
App.showToast('No controls found for selected criteria', 'info');
}
} else {
this.error = data.message || 'Failed to load controls';
}
} catch (error) {
console.error(error);
this.error = 'Failed to load controls';
} finally {
this.loading = false;
}
},
async loadTests() {
this.errors = {};
this.tests = [];
this.test = '';
if (!this.control) {
return;
}
this.loading = true;
try {
const response = await fetch(`${window.BASEURL}/api/entry/tests?controlid=${this.control}`);
const data = await response.json();
if (data.status === 'success') {
this.tests = data.data || [];
if (this.tests.length === 0) {
App.showToast('No tests found for this control', 'info');
}
} else {
this.error = data.message || 'Failed to load tests';
}
} catch (error) {
console.error(error);
this.error = 'Failed to load tests';
} finally {
this.loading = false;
}
},
validate() {
this.errors = {};
if (!this.dept) this.errors.dept = 'Department is required';
if (!this.date) this.errors.date = 'Date is required';
if (!this.control) this.errors.control = 'Control is required';
if (!this.test) this.errors.test = 'Test is required';
if (!this.resvalue) this.errors.resvalue = 'Value is required';
return Object.keys(this.errors).length === 0;
},
async saveResult() {
if (!this.validate()) {
App.showToast('Please fill all required fields', 'error');
return;
}
if (!App.confirmSave('Save result?')) return;
this.loading = true;
this.error = '';
const formData = new FormData();
formData.append('controlid', this.control);
formData.append('testid', this.test);
formData.append('resdate', this.date);
formData.append('resvalue', this.resvalue);
formData.append('rescomment', this.rescomment);
try {
const response = await fetch(`${window.BASEURL}/api/entry/daily`, {
method: 'POST',
body: formData
});
const data = await response.json();
if (data.status === 'success') {
App.showToast('Result saved successfully!');
this.clearForm();
this.saveDraft();
} else {
this.error = data.message || 'Failed to save result';
}
} catch (error) {
console.error(error);
this.error = 'Network error. Please try again.';
} finally {
this.loading = false;
}
},
clearForm() {
this.resvalue = '';
this.rescomment = '';
},
saveDraft() {
localStorage.setItem('dailyEntry', JSON.stringify({
dept: this.dept,
date: this.date,
control: this.control,
test: this.test
}));
},
loadDraft() {
const draft = localStorage.getItem('dailyEntry');
if (draft) {
const data = JSON.parse(draft);
this.dept = data.dept || '';
this.date = data.date || new Date().toISOString().split('T')[0];
this.control = data.control || '';
this.test = data.test || '';
if (this.dept && this.date) this.loadControls();
if (this.control) this.loadTests();
}
}
}));
});
</script>
<?= $this->endSection(); ?>

307
app/Views/entry/monthly.php Normal file
View File

@ -0,0 +1,307 @@
<?= $this->extend("layout/main_layout"); ?>
<?= $this->section("content") ?>
<main x-data="monthlyEntry()">
<div class="bg-white rounded-xl border border-slate-100 shadow-sm p-6">
<div class="flex items-center justify-between mb-6">
<div>
<h1 class="text-2xl font-bold text-slate-800">Monthly Entry</h1>
<p class="text-sm text-slate-500 mt-1">Enter monthly QC results</p>
</div>
<div class="flex items-center gap-2 text-sm text-slate-500">
<i class="fa-solid fa-clock"></i>
<span>Press Ctrl+S to save</span>
</div>
</div>
<div x-show="error" x-transition class="bg-red-50 border border-red-200 text-red-700 px-4 py-3 rounded-lg mb-6">
<div class="flex items-center gap-2">
<i class="fa-solid fa-circle-exclamation"></i>
<span x-text="error"></span>
</div>
</div>
<div class="grid grid-cols-1 md:grid-cols-4 gap-4">
<div>
<label class="block text-sm font-medium text-slate-700 mb-1">Department <span class="text-red-500">*</span></label>
<select x-model="dept" @change="loadControls()" :class="errors.dept ? 'border-red-300 bg-red-50' : ''" class="w-full px-4 py-2.5 text-sm bg-slate-50 border border-slate-200 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500/20 focus:border-blue-500">
<option value="">Select Department</option>
<?php foreach ($depts as $d): ?>
<option value="<?= $d['dept_id'] ?>"><?= $d['name'] ?></option>
<?php endforeach; ?>
</select>
<p x-show="errors.dept" x-text="errors.dept" class="text-red-500 text-xs mt-1"></p>
</div>
<div>
<label class="block text-sm font-medium text-slate-700 mb-1">Date <span class="text-red-500">*</span></label>
<input type="month" x-model="date" @change="loadControls()" :class="errors.date ? 'border-red-300 bg-red-50' : ''" class="w-full px-4 py-2.5 text-sm bg-slate-50 border border-slate-200 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500/20 focus:border-blue-500">
<p x-show="errors.date" x-text="errors.date" class="text-red-500 text-xs mt-1"></p>
</div>
<div>
<label class="block text-sm font-medium text-slate-700 mb-1">Control <span class="text-red-500">*</span></label>
<select x-model="control" @change="loadTests()" :class="errors.control ? 'border-red-300 bg-red-50' : ''" class="w-full px-4 py-2.5 text-sm bg-slate-50 border border-slate-200 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500/20 focus:border-blue-500">
<option value="">Select Control</option>
<template x-for="c in controls" :key="c.control_id">
<option :value="c.control_id" x-text="c.name + ' (' + (c.lot || 'N/A') + ')'"></option>
</template>
</select>
<p x-show="errors.control" x-text="errors.control" class="text-red-500 text-xs mt-1"></p>
</div>
<div>
<label class="block text-sm font-medium text-slate-700 mb-1">Test <span class="text-red-500">*</span></label>
<select x-model="test" :class="errors.test ? 'border-red-300 bg-red-50' : ''" class="w-full px-4 py-2.5 text-sm bg-slate-50 border border-slate-200 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500/20 focus:border-blue-500">
<option value="">Select Test</option>
<template x-for="t in tests" :key="t.test_ref_id">
<option :value="t.test_ref_id" x-text="t.test_name"></option>
</template>
</select>
<p x-show="errors.test" x-text="errors.test" class="text-red-500 text-xs mt-1"></p>
</div>
</div>
<div class="mt-6" x-show="control && test" x-transition>
<button @click="showEntry = true" class="btn btn-primary">
<i class="fa-solid fa-plus mr-2"></i>
Enter Data
</button>
</div>
</div>
<!-- Monthly Entry Modal -->
<div x-show="showEntry"
x-transition:enter="transition ease-out duration-200"
x-transition:enter-start="opacity-0"
x-transition:enter-end="opacity-100"
x-transition:leave="transition ease-in duration-150"
x-transition:leave-start="opacity-100"
x-transition:leave-end="opacity-0"
class="fixed inset-0 bg-slate-900/50 backdrop-blur-sm z-40"
@click="closeEntry()">
</div>
<div x-show="showEntry"
x-cloak
x-transition:enter="transition ease-out duration-200"
x-transition:enter-start="opacity-0 translate-y-4 sm:translate-y-0 sm:scale-95"
x-transition:enter-end="opacity-100 translate-y-0 sm:scale-100"
x-transition:leave="transition ease-in duration-150"
x-transition:leave-start="opacity-100 translate-y-0 sm:scale-100"
x-transition:leave-end="opacity-0 translate-y-4 sm:translate-y-0 sm:scale-95"
class="fixed inset-0 z-50 flex items-center justify-center p-4">
<div class="bg-white rounded-2xl shadow-2xl w-full max-w-5xl" @click.stop>
<div class="px-6 py-4 border-b border-slate-100 flex items-center justify-between">
<h3 class="text-lg font-semibold text-slate-800">Monthly Entry</h3>
<button @click="closeEntry()" class="text-slate-400 hover:text-slate-600">
<i class="fa-solid fa-xmark text-xl"></i>
</button>
</div>
<div class="p-6">
<template x-if="loading">
<div class="flex items-center justify-center py-12">
<i class="fa-solid fa-spinner fa-spin text-blue-500 text-3xl"></i>
</div>
</template>
<template x-if="!loading">
<div class="grid grid-cols-7 gap-2">
<template x-for="day in 31" :key="day">
<div class="text-center">
<label class="block text-xs text-slate-500 mb-1" x-text="day"></label>
<input type="number" step="0.01" :name="'day_' + day" x-model="formValues[day]" class="w-full px-2 py-2 text-sm text-center bg-slate-50 border border-slate-200 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500/20 focus:border-blue-500" placeholder="-">
</div>
</template>
</div>
</template>
</div>
<div class="flex items-center justify-end gap-3 px-6 py-4 border-t border-slate-100 bg-slate-50/50 rounded-b-2xl">
<button @click="closeEntry()" class="px-4 py-2 text-sm font-medium text-slate-600 hover:text-slate-800 transition-colors">Cancel</button>
<button @click="saveData()" data-save-btn :disabled="loading" class="px-4 py-2 text-sm font-medium text-white bg-blue-600 rounded-lg hover:bg-blue-700 disabled:opacity-50 disabled:cursor-not-allowed transition-colors">
<template x-if="!loading">
<span class="flex items-center">
<i class="fa-solid fa-check mr-2"></i>
Save
</span>
</template>
<template x-if="loading">
<span class="flex items-center">
<i class="fa-solid fa-spinner fa-spin mr-2"></i>
Saving...
</span>
</template>
</button>
</div>
</div>
</div>
</main>
<?= $this->endSection(); ?>
<?= $this->section("script") ?>
<script>
document.addEventListener('alpine:init', () => {
Alpine.data("monthlyEntry", () => ({
dept: '',
date: new Date().toISOString().slice(0, 7),
control: '',
test: '',
controls: [],
tests: [],
showEntry: false,
loading: false,
errors: {},
error: '',
formValues: {},
init() {
this.loadDraft();
},
async loadControls() {
this.errors = {};
this.controls = [];
this.control = '';
this.tests = [];
this.test = '';
if (!this.dept || !this.date) {
return;
}
this.loading = true;
try {
const response = await fetch(`${window.BASEURL}/api/entry/controls?date=${this.date}&deptid=${this.dept}`);
const data = await response.json();
if (data.status === 'success') {
this.controls = data.data || [];
if (this.controls.length === 0) {
App.showToast('No controls found for selected criteria', 'info');
}
} else {
this.error = data.message || 'Failed to load controls';
}
} catch (error) {
console.error(error);
this.error = 'Failed to load controls';
} finally {
this.loading = false;
}
},
async loadTests() {
this.errors = {};
this.tests = [];
this.test = '';
if (!this.control) {
return;
}
this.loading = true;
try {
const response = await fetch(`${window.BASEURL}/api/entry/tests?controlid=${this.control}`);
const data = await response.json();
if (data.status === 'success') {
this.tests = data.data || [];
if (this.tests.length === 0) {
App.showToast('No tests found for this control', 'info');
}
} else {
this.error = data.message || 'Failed to load tests';
}
} catch (error) {
console.error(error);
this.error = 'Failed to load tests';
} finally {
this.loading = false;
}
},
validate() {
this.errors = {};
if (!this.dept) this.errors.dept = 'Department is required';
if (!this.date) this.errors.date = 'Date is required';
if (!this.control) this.errors.control = 'Control is required';
if (!this.test) this.errors.test = 'Test is required';
return Object.keys(this.errors).length === 0;
},
async saveData() {
if (!this.validate()) {
App.showToast('Please fill all required fields', 'error');
return;
}
if (!App.confirmSave('Save monthly entry data?')) return;
this.loading = true;
this.error = '';
const formData = new FormData();
formData.append('controlid', this.control);
formData.append('testid', this.test);
formData.append('dates', this.date);
let hasData = false;
for (let day = 1; day <= 31; day++) {
const value = this.formValues[day];
if (value) {
formData.append(`resvalue[${day}]`, value);
hasData = true;
}
}
if (!hasData) {
App.showToast('Please enter at least one value', 'warning');
this.loading = false;
return;
}
try {
const response = await fetch(`${window.BASEURL}/api/entry/monthly`, {
method: 'POST',
body: formData
});
const data = await response.json();
if (data.status === 'success') {
App.showToast('Data saved successfully!');
this.showEntry = false;
this.formValues = {};
this.saveDraft();
} else {
this.error = data.message || 'Failed to save data';
}
} catch (error) {
console.error(error);
this.error = 'Network error. Please try again.';
} finally {
this.loading = false;
}
},
saveDraft() {
localStorage.setItem('monthlyEntry', JSON.stringify({
dept: this.dept,
date: this.date,
control: this.control,
test: this.test
}));
},
loadDraft() {
const draft = localStorage.getItem('monthlyEntry');
if (draft) {
const data = JSON.parse(draft);
this.dept = data.dept || '';
this.date = data.date || new Date().toISOString().slice(0, 7);
this.control = data.control || '';
this.test = data.test || '';
if (this.dept && this.date) this.loadControls();
if (this.control) this.loadTests();
}
},
closeEntry() {
this.showEntry = false;
}
}));
});
</script>
<?= $this->endSection(); ?>

View File

@ -0,0 +1,7 @@
<?php
use CodeIgniter\CLI\CLI;
CLI::error('ERROR: ' . $code);
CLI::write($message);
CLI::newLine();

View File

@ -0,0 +1,65 @@
<?php
use CodeIgniter\CLI\CLI;
// The main Exception
CLI::write('[' . $exception::class . ']', 'light_gray', 'red');
CLI::write($message);
CLI::write('at ' . CLI::color(clean_path($exception->getFile()) . ':' . $exception->getLine(), 'green'));
CLI::newLine();
$last = $exception;
while ($prevException = $last->getPrevious()) {
$last = $prevException;
CLI::write(' Caused by:');
CLI::write(' [' . $prevException::class . ']', 'red');
CLI::write(' ' . $prevException->getMessage());
CLI::write(' at ' . CLI::color(clean_path($prevException->getFile()) . ':' . $prevException->getLine(), 'green'));
CLI::newLine();
}
// The backtrace
if (defined('SHOW_DEBUG_BACKTRACE') && SHOW_DEBUG_BACKTRACE) {
$backtraces = $last->getTrace();
if ($backtraces) {
CLI::write('Backtrace:', 'green');
}
foreach ($backtraces as $i => $error) {
$padFile = ' '; // 4 spaces
$padClass = ' '; // 7 spaces
$c = str_pad($i + 1, 3, ' ', STR_PAD_LEFT);
if (isset($error['file'])) {
$filepath = clean_path($error['file']) . ':' . $error['line'];
CLI::write($c . $padFile . CLI::color($filepath, 'yellow'));
} else {
CLI::write($c . $padFile . CLI::color('[internal function]', 'yellow'));
}
$function = '';
if (isset($error['class'])) {
$type = ($error['type'] === '->') ? '()' . $error['type'] : $error['type'];
$function .= $padClass . $error['class'] . $type . $error['function'];
} elseif (! isset($error['class']) && isset($error['function'])) {
$function .= $padClass . $error['function'];
}
$args = implode(', ', array_map(static fn ($value): string => match (true) {
is_object($value) => 'Object(' . $value::class . ')',
is_array($value) => $value !== [] ? '[...]' : '[]',
$value === null => 'null', // return the lowercased version
default => var_export($value, true),
}, array_values($error['args'] ?? [])));
$function .= '(' . $args . ')';
CLI::write($function);
CLI::newLine();
}
}

View File

@ -0,0 +1,5 @@
<?php
// On the CLI, we still want errors in productions
// so just use the exception template.
include __DIR__ . '/error_exception.php';

View File

@ -0,0 +1,194 @@
:root {
--main-bg-color: #fff;
--main-text-color: #555;
--dark-text-color: #222;
--light-text-color: #c7c7c7;
--brand-primary-color: #DC4814;
--light-bg-color: #ededee;
--dark-bg-color: #404040;
}
body {
height: 100%;
background: var(--main-bg-color);
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji";
color: var(--main-text-color);
font-weight: 300;
margin: 0;
padding: 0;
}
h1 {
font-weight: lighter;
font-size: 3rem;
color: var(--dark-text-color);
margin: 0;
}
h1.headline {
margin-top: 20%;
font-size: 5rem;
}
.text-center {
text-align: center;
}
p.lead {
font-size: 1.6rem;
}
.container {
max-width: 75rem;
margin: 0 auto;
padding: 1rem;
}
.header {
background: var(--light-bg-color);
color: var(--dark-text-color);
margin-top: 2.17rem;
}
.header .container {
padding: 1rem;
}
.header h1 {
font-size: 2.5rem;
font-weight: 500;
}
.header p {
font-size: 1.2rem;
margin: 0;
line-height: 2.5;
}
.header a {
color: var(--brand-primary-color);
margin-left: 2rem;
display: none;
text-decoration: none;
}
.header:hover a {
display: inline;
}
.environment {
background: var(--brand-primary-color);
color: var(--main-bg-color);
text-align: center;
padding: calc(4px + 0.2083vw);
width: 100%;
top: 0;
position: fixed;
}
.source {
background: #343434;
color: var(--light-text-color);
padding: 0.5em 1em;
border-radius: 5px;
font-family: Menlo, Monaco, Consolas, "Courier New", monospace;
font-size: 0.85rem;
margin: 0;
overflow-x: scroll;
}
.source span.line {
line-height: 1.4;
}
.source span.line .number {
color: #666;
}
.source .line .highlight {
display: block;
background: var(--dark-text-color);
color: var(--light-text-color);
}
.source span.highlight .number {
color: #fff;
}
.tabs {
list-style: none;
list-style-position: inside;
margin: 0;
padding: 0;
margin-bottom: -1px;
}
.tabs li {
display: inline;
}
.tabs a:link,
.tabs a:visited {
padding: 0 1rem;
line-height: 2.7;
text-decoration: none;
color: var(--dark-text-color);
background: var(--light-bg-color);
border: 1px solid rgba(0,0,0,0.15);
border-bottom: 0;
border-top-left-radius: 5px;
border-top-right-radius: 5px;
display: inline-block;
}
.tabs a:hover {
background: var(--light-bg-color);
border-color: rgba(0,0,0,0.15);
}
.tabs a.active {
background: var(--main-bg-color);
color: var(--main-text-color);
}
.tab-content {
background: var(--main-bg-color);
border: 1px solid rgba(0,0,0,0.15);
}
.content {
padding: 1rem;
}
.hide {
display: none;
}
.alert {
margin-top: 2rem;
display: block;
text-align: center;
line-height: 3.0;
background: #d9edf7;
border: 1px solid #bcdff1;
border-radius: 5px;
color: #31708f;
}
table {
width: 100%;
overflow: hidden;
}
th {
text-align: left;
border-bottom: 1px solid #e7e7e7;
padding-bottom: 0.5rem;
}
td {
padding: 0.2rem 0.5rem 0.2rem 0;
}
tr:hover td {
background: #f1f1f1;
}
td pre {
white-space: pre-wrap;
}
.trace a {
color: inherit;
}
.trace table {
width: auto;
}
.trace tr td:first-child {
min-width: 5em;
font-weight: bold;
}
.trace td {
background: var(--light-bg-color);
padding: 0 1rem;
}
.trace td pre {
margin: 0;
}
.args {
display: none;
}

View File

@ -0,0 +1,116 @@
var tabLinks = new Array();
var contentDivs = new Array();
function init()
{
// Grab the tab links and content divs from the page
var tabListItems = document.getElementById('tabs').childNodes;
console.log(tabListItems);
for (var i = 0; i < tabListItems.length; i ++)
{
if (tabListItems[i].nodeName == "LI")
{
var tabLink = getFirstChildWithTagName(tabListItems[i], 'A');
var id = getHash(tabLink.getAttribute('href'));
tabLinks[id] = tabLink;
contentDivs[id] = document.getElementById(id);
}
}
// Assign onclick events to the tab links, and
// highlight the first tab
var i = 0;
for (var id in tabLinks)
{
tabLinks[id].onclick = showTab;
tabLinks[id].onfocus = function () {
this.blur()
};
if (i == 0)
{
tabLinks[id].className = 'active';
}
i ++;
}
// Hide all content divs except the first
var i = 0;
for (var id in contentDivs)
{
if (i != 0)
{
console.log(contentDivs[id]);
contentDivs[id].className = 'content hide';
}
i ++;
}
}
function showTab()
{
var selectedId = getHash(this.getAttribute('href'));
// Highlight the selected tab, and dim all others.
// Also show the selected content div, and hide all others.
for (var id in contentDivs)
{
if (id == selectedId)
{
tabLinks[id].className = 'active';
contentDivs[id].className = 'content';
}
else
{
tabLinks[id].className = '';
contentDivs[id].className = 'content hide';
}
}
// Stop the browser following the link
return false;
}
function getFirstChildWithTagName(element, tagName)
{
for (var i = 0; i < element.childNodes.length; i ++)
{
if (element.childNodes[i].nodeName == tagName)
{
return element.childNodes[i];
}
}
}
function getHash(url)
{
var hashPos = url.lastIndexOf('#');
return url.substring(hashPos + 1);
}
function toggle(elem)
{
elem = document.getElementById(elem);
if (elem.style && elem.style['display'])
{
// Only works with the "style" attr
var disp = elem.style['display'];
}
else if (elem.currentStyle)
{
// For MSIE, naturally
var disp = elem.currentStyle['display'];
}
else if (window.getComputedStyle)
{
// For most other browsers
var disp = document.defaultView.getComputedStyle(elem, null).getPropertyValue('display');
}
// Toggle the state of the "display" style
elem.style.display = disp == 'block' ? 'none' : 'block';
return false;
}

View File

@ -0,0 +1,84 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title><?= lang('Errors.badRequest') ?></title>
<style>
div.logo {
height: 200px;
width: 155px;
display: inline-block;
opacity: 0.08;
position: absolute;
top: 2rem;
left: 50%;
margin-left: -73px;
}
body {
height: 100%;
background: #fafafa;
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
color: #777;
font-weight: 300;
}
h1 {
font-weight: lighter;
letter-spacing: normal;
font-size: 3rem;
margin-top: 0;
margin-bottom: 0;
color: #222;
}
.wrap {
max-width: 1024px;
margin: 5rem auto;
padding: 2rem;
background: #fff;
text-align: center;
border: 1px solid #efefef;
border-radius: 0.5rem;
position: relative;
}
pre {
white-space: normal;
margin-top: 1.5rem;
}
code {
background: #fafafa;
border: 1px solid #efefef;
padding: 0.5rem 1rem;
border-radius: 5px;
display: block;
}
p {
margin-top: 1.5rem;
}
.footer {
margin-top: 2rem;
border-top: 1px solid #efefef;
padding: 1em 2em 0 2em;
font-size: 85%;
color: #999;
}
a:active,
a:link,
a:visited {
color: #dd4814;
}
</style>
</head>
<body>
<div class="wrap">
<h1>400</h1>
<p>
<?php if (ENVIRONMENT !== 'production') : ?>
<?= nl2br(esc($message)) ?>
<?php else : ?>
<?= lang('Errors.sorryBadRequest') ?>
<?php endif; ?>
</p>
</div>
</body>
</html>

View File

@ -0,0 +1,84 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title><?= lang('Errors.pageNotFound') ?></title>
<style>
div.logo {
height: 200px;
width: 155px;
display: inline-block;
opacity: 0.08;
position: absolute;
top: 2rem;
left: 50%;
margin-left: -73px;
}
body {
height: 100%;
background: #fafafa;
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
color: #777;
font-weight: 300;
}
h1 {
font-weight: lighter;
letter-spacing: normal;
font-size: 3rem;
margin-top: 0;
margin-bottom: 0;
color: #222;
}
.wrap {
max-width: 1024px;
margin: 5rem auto;
padding: 2rem;
background: #fff;
text-align: center;
border: 1px solid #efefef;
border-radius: 0.5rem;
position: relative;
}
pre {
white-space: normal;
margin-top: 1.5rem;
}
code {
background: #fafafa;
border: 1px solid #efefef;
padding: 0.5rem 1rem;
border-radius: 5px;
display: block;
}
p {
margin-top: 1.5rem;
}
.footer {
margin-top: 2rem;
border-top: 1px solid #efefef;
padding: 1em 2em 0 2em;
font-size: 85%;
color: #999;
}
a:active,
a:link,
a:visited {
color: #dd4814;
}
</style>
</head>
<body>
<div class="wrap">
<h1>404</h1>
<p>
<?php if (ENVIRONMENT !== 'production') : ?>
<?= nl2br(esc($message)) ?>
<?php else : ?>
<?= lang('Errors.sorryCannotFind') ?>
<?php endif; ?>
</p>
</div>
</body>
</html>

View File

@ -0,0 +1,429 @@
<?php
use CodeIgniter\HTTP\Header;
use CodeIgniter\CodeIgniter;
$errorId = uniqid('error', true);
?>
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<meta name="robots" content="noindex">
<title><?= esc($title) ?></title>
<style>
<?= preg_replace('#[\r\n\t ]+#', ' ', file_get_contents(__DIR__ . DIRECTORY_SEPARATOR . 'debug.css')) ?>
</style>
<script>
<?= file_get_contents(__DIR__ . DIRECTORY_SEPARATOR . 'debug.js') ?>
</script>
</head>
<body onload="init()">
<!-- Header -->
<div class="header">
<div class="environment">
Displayed at <?= esc(date('H:i:s')) ?> &mdash;
PHP: <?= esc(PHP_VERSION) ?> &mdash;
CodeIgniter: <?= esc(CodeIgniter::CI_VERSION) ?> --
Environment: <?= ENVIRONMENT ?>
</div>
<div class="container">
<h1><?= esc($title), esc($exception->getCode() ? ' #' . $exception->getCode() : '') ?></h1>
<p>
<?= nl2br(esc($exception->getMessage())) ?>
<a href="https://www.duckduckgo.com/?q=<?= urlencode($title . ' ' . preg_replace('#\'.*\'|".*"#Us', '', $exception->getMessage())) ?>"
rel="noreferrer" target="_blank">search &rarr;</a>
</p>
</div>
</div>
<!-- Source -->
<div class="container">
<p><b><?= esc(clean_path($file)) ?></b> at line <b><?= esc($line) ?></b></p>
<?php if (is_file($file)) : ?>
<div class="source">
<?= static::highlightFile($file, $line, 15); ?>
</div>
<?php endif; ?>
</div>
<div class="container">
<?php
$last = $exception;
while ($prevException = $last->getPrevious()) {
$last = $prevException;
?>
<pre>
Caused by:
<?= esc($prevException::class), esc($prevException->getCode() ? ' #' . $prevException->getCode() : '') ?>
<?= nl2br(esc($prevException->getMessage())) ?>
<a href="https://www.duckduckgo.com/?q=<?= urlencode($prevException::class . ' ' . preg_replace('#\'.*\'|".*"#Us', '', $prevException->getMessage())) ?>"
rel="noreferrer" target="_blank">search &rarr;</a>
<?= esc(clean_path($prevException->getFile()) . ':' . $prevException->getLine()) ?>
</pre>
<?php
}
?>
</div>
<?php if (defined('SHOW_DEBUG_BACKTRACE') && SHOW_DEBUG_BACKTRACE) : ?>
<div class="container">
<ul class="tabs" id="tabs">
<li><a href="#backtrace">Backtrace</a></li>
<li><a href="#server">Server</a></li>
<li><a href="#request">Request</a></li>
<li><a href="#response">Response</a></li>
<li><a href="#files">Files</a></li>
<li><a href="#memory">Memory</a></li>
</ul>
<div class="tab-content">
<!-- Backtrace -->
<div class="content" id="backtrace">
<ol class="trace">
<?php foreach ($trace as $index => $row) : ?>
<li>
<p>
<!-- Trace info -->
<?php if (isset($row['file']) && is_file($row['file'])) : ?>
<?php
if (isset($row['function']) && in_array($row['function'], ['include', 'include_once', 'require', 'require_once'], true)) {
echo esc($row['function'] . ' ' . clean_path($row['file']));
} else {
echo esc(clean_path($row['file']) . ' : ' . $row['line']);
}
?>
<?php else: ?>
{PHP internal code}
<?php endif; ?>
<!-- Class/Method -->
<?php if (isset($row['class'])) : ?>
&nbsp;&nbsp;&mdash;&nbsp;&nbsp;<?= esc($row['class'] . $row['type'] . $row['function']) ?>
<?php if (! empty($row['args'])) : ?>
<?php $argsId = $errorId . 'args' . $index ?>
( <a href="#" onclick="return toggle('<?= esc($argsId, 'attr') ?>');">arguments</a> )
<div class="args" id="<?= esc($argsId, 'attr') ?>">
<table cellspacing="0">
<?php
$params = null;
// Reflection by name is not available for closure function
if (! str_ends_with($row['function'], '}')) {
$mirror = isset($row['class']) ? new ReflectionMethod($row['class'], $row['function']) : new ReflectionFunction($row['function']);
$params = $mirror->getParameters();
}
foreach ($row['args'] as $key => $value) : ?>
<tr>
<td><code><?= esc(isset($params[$key]) ? '$' . $params[$key]->name : "#{$key}") ?></code></td>
<td><pre><?= esc(print_r($value, true)) ?></pre></td>
</tr>
<?php endforeach ?>
</table>
</div>
<?php else : ?>
()
<?php endif; ?>
<?php endif; ?>
<?php if (! isset($row['class']) && isset($row['function'])) : ?>
&nbsp;&nbsp;&mdash;&nbsp;&nbsp; <?= esc($row['function']) ?>()
<?php endif; ?>
</p>
<!-- Source? -->
<?php if (isset($row['file']) && is_file($row['file']) && isset($row['class'])) : ?>
<div class="source">
<?= static::highlightFile($row['file'], $row['line']) ?>
</div>
<?php endif; ?>
</li>
<?php endforeach; ?>
</ol>
</div>
<!-- Server -->
<div class="content" id="server">
<?php foreach (['_SERVER', '_SESSION'] as $var) : ?>
<?php
if (empty($GLOBALS[$var]) || ! is_array($GLOBALS[$var])) {
continue;
} ?>
<h3>$<?= esc($var) ?></h3>
<table>
<thead>
<tr>
<th>Key</th>
<th>Value</th>
</tr>
</thead>
<tbody>
<?php foreach ($GLOBALS[$var] as $key => $value) : ?>
<tr>
<td><?= esc($key) ?></td>
<td>
<?php if (is_string($value)) : ?>
<?= esc($value) ?>
<?php else: ?>
<pre><?= esc(print_r($value, true)) ?></pre>
<?php endif; ?>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<?php endforeach ?>
<!-- Constants -->
<?php $constants = get_defined_constants(true); ?>
<?php if (! empty($constants['user'])) : ?>
<h3>Constants</h3>
<table>
<thead>
<tr>
<th>Key</th>
<th>Value</th>
</tr>
</thead>
<tbody>
<?php foreach ($constants['user'] as $key => $value) : ?>
<tr>
<td><?= esc($key) ?></td>
<td>
<?php if (is_string($value)) : ?>
<?= esc($value) ?>
<?php else: ?>
<pre><?= esc(print_r($value, true)) ?></pre>
<?php endif; ?>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<?php endif; ?>
</div>
<!-- Request -->
<div class="content" id="request">
<?php $request = service('request'); ?>
<table>
<tbody>
<tr>
<td style="width: 10em">Path</td>
<td><?= esc($request->getUri()) ?></td>
</tr>
<tr>
<td>HTTP Method</td>
<td><?= esc($request->getMethod()) ?></td>
</tr>
<tr>
<td>IP Address</td>
<td><?= esc($request->getIPAddress()) ?></td>
</tr>
<tr>
<td style="width: 10em">Is AJAX Request?</td>
<td><?= $request->isAJAX() ? 'yes' : 'no' ?></td>
</tr>
<tr>
<td>Is CLI Request?</td>
<td><?= $request->isCLI() ? 'yes' : 'no' ?></td>
</tr>
<tr>
<td>Is Secure Request?</td>
<td><?= $request->isSecure() ? 'yes' : 'no' ?></td>
</tr>
<tr>
<td>User Agent</td>
<td><?= esc($request->getUserAgent()->getAgentString()) ?></td>
</tr>
</tbody>
</table>
<?php $empty = true; ?>
<?php foreach (['_GET', '_POST', '_COOKIE'] as $var) : ?>
<?php
if (empty($GLOBALS[$var]) || ! is_array($GLOBALS[$var])) {
continue;
} ?>
<?php $empty = false; ?>
<h3>$<?= esc($var) ?></h3>
<table style="width: 100%">
<thead>
<tr>
<th>Key</th>
<th>Value</th>
</tr>
</thead>
<tbody>
<?php foreach ($GLOBALS[$var] as $key => $value) : ?>
<tr>
<td><?= esc($key) ?></td>
<td>
<?php if (is_string($value)) : ?>
<?= esc($value) ?>
<?php else: ?>
<pre><?= esc(print_r($value, true)) ?></pre>
<?php endif; ?>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<?php endforeach ?>
<?php if ($empty) : ?>
<div class="alert">
No $_GET, $_POST, or $_COOKIE Information to show.
</div>
<?php endif; ?>
<?php $headers = $request->headers(); ?>
<?php if (! empty($headers)) : ?>
<h3>Headers</h3>
<table>
<thead>
<tr>
<th>Header</th>
<th>Value</th>
</tr>
</thead>
<tbody>
<?php foreach ($headers as $name => $value) : ?>
<tr>
<td><?= esc($name, 'html') ?></td>
<td>
<?php
if ($value instanceof Header) {
echo esc($value->getValueLine(), 'html');
} else {
foreach ($value as $i => $header) {
echo ' ('. $i+1 . ') ' . esc($header->getValueLine(), 'html');
}
}
?>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<?php endif; ?>
</div>
<!-- Response -->
<?php
$response = service('response');
$response->setStatusCode(http_response_code());
?>
<div class="content" id="response">
<table>
<tr>
<td style="width: 15em">Response Status</td>
<td><?= esc($response->getStatusCode() . ' - ' . $response->getReasonPhrase()) ?></td>
</tr>
</table>
<?php $headers = $response->headers(); ?>
<?php if (! empty($headers)) : ?>
<h3>Headers</h3>
<table>
<thead>
<tr>
<th>Header</th>
<th>Value</th>
</tr>
</thead>
<tbody>
<?php foreach ($headers as $name => $value) : ?>
<tr>
<td><?= esc($name, 'html') ?></td>
<td>
<?php
if ($value instanceof Header) {
echo esc($response->getHeaderLine($name), 'html');
} else {
foreach ($value as $i => $header) {
echo ' ('. $i+1 . ') ' . esc($header->getValueLine(), 'html');
}
}
?>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<?php endif; ?>
</div>
<!-- Files -->
<div class="content" id="files">
<?php $files = get_included_files(); ?>
<ol>
<?php foreach ($files as $file) :?>
<li><?= esc(clean_path($file)) ?></li>
<?php endforeach ?>
</ol>
</div>
<!-- Memory -->
<div class="content" id="memory">
<table>
<tbody>
<tr>
<td>Memory Usage</td>
<td><?= esc(static::describeMemory(memory_get_usage(true))) ?></td>
</tr>
<tr>
<td style="width: 12em">Peak Memory Usage:</td>
<td><?= esc(static::describeMemory(memory_get_peak_usage(true))) ?></td>
</tr>
<tr>
<td>Memory Limit:</td>
<td><?= esc(ini_get('memory_limit')) ?></td>
</tr>
</tbody>
</table>
</div>
</div> <!-- /tab-content -->
</div> <!-- /container -->
<?php endif; ?>
</body>
</html>

View File

@ -0,0 +1,25 @@
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<meta name="robots" content="noindex">
<title><?= lang('Errors.whoops') ?></title>
<style>
<?= preg_replace('#[\r\n\t ]+#', ' ', file_get_contents(__DIR__ . DIRECTORY_SEPARATOR . 'debug.css')) ?>
</style>
</head>
<body>
<div class="container text-center">
<h1 class="headline"><?= lang('Errors.whoops') ?></h1>
<p class="lead"><?= lang('Errors.weHitASnag') ?></p>
</div>
</body>
</html>

Some files were not shown because too many files have changed in this diff Show More