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
2026-01-14 16:49:27 +07:00
|
|
|
<?php
|
2026-01-19 06:37:37 +07:00
|
|
|
namespace App\Controllers\Qc;
|
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
2026-01-14 16:49:27 +07:00
|
|
|
|
2026-01-19 06:37:37 +07:00
|
|
|
use CodeIgniter\API\ResponseTrait;
|
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
2026-01-14 16:49:27 +07:00
|
|
|
use App\Controllers\BaseController;
|
2026-01-19 06:37:37 +07:00
|
|
|
use App\Models\Qc\ControlTestsModel;
|
|
|
|
|
|
2026-01-21 13:41:37 +07:00
|
|
|
class ControlTestsController extends BaseController
|
|
|
|
|
{
|
2026-01-19 06:37:37 +07:00
|
|
|
use ResponseTrait;
|
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
2026-01-14 16:49:27 +07:00
|
|
|
|
2026-01-19 06:37:37 +07:00
|
|
|
protected $model;
|
2026-01-21 13:41:37 +07:00
|
|
|
protected $rules = [
|
|
|
|
|
'controlId' => 'required|numeric',
|
|
|
|
|
'testId' => 'required|numeric',
|
|
|
|
|
'mean' => 'required|decimal',
|
|
|
|
|
'sd' => 'required|decimal',
|
|
|
|
|
];
|
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
2026-01-14 16:49:27 +07:00
|
|
|
|
2026-01-21 13:41:37 +07:00
|
|
|
public function __construct()
|
|
|
|
|
{
|
2026-01-19 06:37:37 +07:00
|
|
|
$this->model = new ControlTestsModel();
|
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
2026-01-14 16:49:27 +07:00
|
|
|
}
|
|
|
|
|
|
2026-01-21 13:41:37 +07:00
|
|
|
public function index()
|
|
|
|
|
{
|
2026-01-19 06:37:37 +07:00
|
|
|
$keyword = $this->request->getGet('keyword');
|
2026-01-21 13:41:37 +07:00
|
|
|
return $this->respond([
|
|
|
|
|
'status' => 'success',
|
|
|
|
|
'data' => $this->model->search($keyword)
|
|
|
|
|
]);
|
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
2026-01-14 16:49:27 +07:00
|
|
|
}
|
|
|
|
|
|
2026-01-21 13:41:37 +07:00
|
|
|
public function create()
|
|
|
|
|
{
|
2026-01-15 10:44:09 +07:00
|
|
|
$input = $this->request->getJSON(true);
|
|
|
|
|
if (!$this->validate($this->rules)) {
|
|
|
|
|
return $this->failValidationErrors($this->validator->getErrors());
|
|
|
|
|
}
|
2026-01-21 13:41:37 +07:00
|
|
|
|
2026-01-15 10:44:09 +07:00
|
|
|
try {
|
2026-01-21 13:41:37 +07:00
|
|
|
$id = $this->model->insert($input);
|
|
|
|
|
return $this->respondCreated(['status' => 'success', 'data' => $id]);
|
2026-01-15 10:44:09 +07:00
|
|
|
} catch (\Exception $e) {
|
2026-01-19 06:37:37 +07:00
|
|
|
return $this->failServerError($e->getMessage());
|
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
2026-01-14 16:49:27 +07:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-01-21 13:41:37 +07:00
|
|
|
public function update($id = null)
|
|
|
|
|
{
|
2026-01-15 10:44:09 +07:00
|
|
|
$input = $this->request->getJSON(true);
|
|
|
|
|
if (!$this->validate($this->rules)) {
|
|
|
|
|
return $this->failValidationErrors($this->validator->getErrors());
|
|
|
|
|
}
|
2026-01-21 13:41:37 +07:00
|
|
|
|
2026-01-15 10:44:09 +07:00
|
|
|
try {
|
2026-01-19 06:37:37 +07:00
|
|
|
$this->model->update($id, $input);
|
2026-01-21 13:41:37 +07:00
|
|
|
return $this->respond(['status' => 'success']);
|
2026-01-15 10:44:09 +07:00
|
|
|
} catch (\Exception $e) {
|
2026-01-19 06:37:37 +07:00
|
|
|
return $this->failServerError($e->getMessage());
|
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
2026-01-14 16:49:27 +07:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-01-21 13:41:37 +07:00
|
|
|
public function delete($id = null)
|
|
|
|
|
{
|
2026-01-15 10:44:09 +07:00
|
|
|
try {
|
2026-01-19 06:37:37 +07:00
|
|
|
$this->model->delete($id);
|
2026-01-21 13:41:37 +07:00
|
|
|
return $this->respond(['status' => 'success']);
|
2026-01-15 10:44:09 +07:00
|
|
|
} catch (\Exception $e) {
|
2026-01-19 06:37:37 +07:00
|
|
|
return $this->failServerError($e->getMessage());
|
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
2026-01-14 16:49:27 +07:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|