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
|
|
|
|
|
|
|
|
|
|
namespace App\Models;
|
|
|
|
|
|
2026-01-15 10:44:09 +07:00
|
|
|
use App\Models\BaseModel;
|
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-15 10:44:09 +07:00
|
|
|
class ControlTestModel extends BaseModel
|
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
|
|
|
{
|
|
|
|
|
protected $table = 'control_tests';
|
|
|
|
|
protected $primaryKey = 'control_test_id';
|
|
|
|
|
protected $useAutoIncrement = true;
|
|
|
|
|
protected $returnType = 'array';
|
2026-01-15 10:44:09 +07:00
|
|
|
protected $useSoftDeletes = true;
|
|
|
|
|
protected $useTimestamps = true;
|
|
|
|
|
protected $allowedFields = ['control_ref_id', 'test_ref_id', 'mean', 'sd'];
|
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
|
|
|
|
|
|
|
|
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();
|
|
|
|
|
}
|
|
|
|
|
}
|