Control Dictionary
-Manage control materials and lot numbers
-Loading controls...
-No controls found
-| # | -Name | -Lot | -Department | -Status | -Expiry Date | -Actions | -
|---|---|---|---|---|---|---|
| - | - | - - | -- | - - | -- | - - - | -
diff --git a/app/Config/Routes.php b/app/Config/Routes.php index e81430f..b608135 100644 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -7,6 +7,9 @@ use CodeIgniter\Router\RouteCollection; */ $routes->get('/', 'PageController::dashboard'); +$routes->get('/master/dept', 'PageController::masterDept'); +$routes->get('/master/test', 'PageController::masterTest'); +$routes->get('/master/control', 'PageController::masterControl'); $routes->get('/dept', 'PageController::dept'); $routes->get('/test', 'PageController::test'); $routes->get('/control', 'PageController::control'); @@ -42,3 +45,43 @@ $routes->group('api', function ($routes) { $routes->post('entry/monthly', 'Api\EntryApiController::saveMonthly'); $routes->post('entry/comment', 'Api\EntryApiController::saveComment'); }); + + $routes->group('api/master', function ($routes) { + $routes->get('depts', 'Master\MasterDeptsController::index'); + $routes->get('depts/(:num)', 'Master\MasterDeptsController::show/$1'); + $routes->post('depts', 'Master\MasterDeptsController::create'); + $routes->patch('depts/(:num)', 'Master\MasterDeptsController::update/$1'); + $routes->delete('depts/(:num)', 'Master\MasterDeptsController::delete/$1'); + + $routes->get('controls', 'Master\MasterControlsController::index'); + $routes->get('controls/(:num)', 'Master\MasterControlsController::show/$1'); + $routes->post('controls', 'Master\MasterControlsController::create'); + $routes->patch('controls/(:num)', 'Master\MasterControlsController::update/$1'); + $routes->delete('controls/(:num)', 'Master\MasterControlsController::delete/$1'); + + $routes->get('tests', 'Master\MasterTestsController::index'); + $routes->get('tests/(:num)', 'Master\MasterTestsController::show/$1'); + $routes->post('tests', 'Master\MasterTestsController::create'); + $routes->patch('tests/(:num)', 'Master\MasterTestsController::update/$1'); + $routes->delete('tests/(:num)', 'Master\MasterTestsController::delete/$1'); +}); + +$routes->group('api/qc', function ($routes) { + $routes->get('control-tests', 'Qc\ControlTestsController::index'); + $routes->get('control-tests/(:num)', 'Qc\ControlTestsController::show/$1'); + $routes->post('control-tests', 'Qc\ControlTestsController::create'); + $routes->patch('control-tests/(:num)', 'Qc\ControlTestsController::update/$1'); + $routes->delete('control-tests/(:num)', 'Qc\ControlTestsController::delete/$1'); + + $routes->get('results', 'Qc\ResultsController::index'); + $routes->get('results/(:num)', 'Qc\ResultsController::show/$1'); + $routes->post('results', 'Qc\ResultsController::create'); + $routes->patch('results/(:num)', 'Qc\ResultsController::update/$1'); + $routes->delete('results/(:num)', 'Qc\ResultsController::delete/$1'); + + $routes->get('result-comments', 'Qc\ResultCommentsController::index'); + $routes->get('result-comments/(:num)', 'Qc\ResultCommentsController::show/$1'); + $routes->post('result-comments', 'Qc\ResultCommentsController::create'); + $routes->patch('result-comments/(:num)', 'Qc\ResultCommentsController::update/$1'); + $routes->delete('result-comments/(:num)', 'Qc\ResultCommentsController::delete/$1'); +}); diff --git a/app/Controllers/Api/ControlApiController.php b/app/Controllers/Api/ControlApiController.php deleted file mode 100644 index e375076..0000000 --- a/app/Controllers/Api/ControlApiController.php +++ /dev/null @@ -1,148 +0,0 @@ -dictControlModel = new DictControlModel(); - $this->controlTestModel = new ControlTestModel(); - $this->rules = [ - 'name' => 'required|min_length[1]', - 'dept_ref_id' => 'required', - ]; - } - - public function index() - { - $keyword = $this->request->getGet('keyword'); - $deptId = $this->request->getGet('deptId'); - try { - $rows = $this->dictControlModel->getWithDept($keyword, $deptId); - return $this->respond([ - 'status' => 'success', - 'message' => 'fetch success', - 'data' => $rows - ], 200); - } catch (\Exception $e) { - return $this->failServerError('Exception: ' . $e->getMessage()); - } - } - - public function show($id = null) - { - try { - $rows = $this->dictControlModel->where('control_id', $id)->findAll(); - if (empty($rows)) { - return $this->respond([ - 'status' => 'success', - 'message' => 'data not found.' - ], 200); - } - return $this->respond([ - 'status' => 'success', - 'message' => 'fetch success', - 'data' => $rows - ], 200); - } catch (\Exception $e) { - return $this->failServerError('Something went wrong: ' . $e->getMessage()); - } - } - - public function getTests($id = null) - { - try { - $rows = $this->controlTestModel->where('control_ref_id', $id)->findAll(); - return $this->respond([ - 'status' => 'success', - 'message' => 'fetch success', - 'data' => $rows - ], 200); - } catch (\Exception $e) { - return $this->failServerError('Something went wrong: ' . $e->getMessage()); - } - } - - public function create() - { - $input = $this->request->getJSON(true); - if (!$this->validate($this->rules)) { - return $this->failValidationErrors($this->validator->getErrors()); - } - try { - $controlId = $this->dictControlModel->insert($input, true); - - if (!empty($input['test_ids'])) { - foreach ($input['test_ids'] as $testId) { - $this->controlTestModel->insert([ - 'control_ref_id' => $controlId, - 'test_ref_id' => $testId, - 'mean' => 0, - 'sd' => 0, - ]); - } - } - - return $this->respondCreated([ - 'status' => 'success', - 'message' => $controlId - ]); - } catch (\Exception $e) { - return $this->failServerError('Something went wrong: ' . $e->getMessage()); - } - } - - public function update($id = null) - { - $input = $this->request->getJSON(true); - if (!$this->validate($this->rules)) { - return $this->failValidationErrors($this->validator->getErrors()); - } - try { - $this->dictControlModel->update($id, $input); - - if (!empty($input['test_ids'])) { - $this->controlTestModel->where('control_ref_id', $id)->delete(); - foreach ($input['test_ids'] as $testId) { - $this->controlTestModel->insert([ - 'control_ref_id' => $id, - 'test_ref_id' => $testId, - 'mean' => 0, - 'sd' => 0, - ]); - } - } - - return $this->respond([ - 'status' => 'success', - 'message' => 'update success', - 'data' => $id - ]); - } catch (\Exception $e) { - return $this->failServerError('Something went wrong: ' . $e->getMessage()); - } - } - - public function delete($id = null) - { - try { - $this->controlTestModel->where('control_ref_id', $id)->delete(); - $this->dictControlModel->delete($id); - return $this->respond([ - 'status' => 'success', - 'message' => 'delete success' - ]); - } catch (\Exception $e) { - return $this->failServerError('Something went wrong: ' . $e->getMessage()); - } - } -} diff --git a/app/Controllers/Api/EntryApiController.php b/app/Controllers/Api/EntryApiController.php deleted file mode 100644 index b8971a1..0000000 --- a/app/Controllers/Api/EntryApiController.php +++ /dev/null @@ -1,252 +0,0 @@ -dictControlModel = new \App\Models\DictControlModel(); - $this->controlTestModel = new \App\Models\ControlTestModel(); - $this->dailyResultModel = new \App\Models\DailyResultModel(); - $this->resultModel = new \App\Models\ResultModel(); - $this->commentModel = new \App\Models\ResultCommentModel(); - } - - public function getControls() - { - try { - $date = $this->request->getGet('date'); - $deptId = $this->request->getGet('deptId'); - - $rows = $this->dictControlModel->getActiveByDate($date, $deptId); - return $this->respond([ - 'status' => 'success', - 'message' => 'fetch success', - 'data' => $rows - ], 200); - } catch (\Exception $e) { - return $this->failServerError('Something went wrong: ' . $e->getMessage()); - } - } - - public function getTests() - { - try { - $controlId = $this->request->getGet('controlId'); - - $rows = $this->controlTestModel->getByControl($controlId); - return $this->respond([ - 'status' => 'success', - 'message' => 'fetch success', - 'data' => $rows - ], 200); - } catch (\Exception $e) { - return $this->failServerError('Something went wrong: ' . $e->getMessage()); - } - } - - public function saveDaily() - { - $input = $this->request->getJSON(true); - - try { - $resultData = [ - 'control_ref_id' => $input['controlId'] ?? 0, - 'test_ref_id' => $input['testId'] ?? 0, - 'resdate' => $input['resdate'] ?? date('Y-m-d'), - 'resvalue' => $input['resvalue'] ?? '', - 'rescomment' => $input['rescomment'] ?? '', - ]; - - $this->dailyResultModel->saveResult($resultData); - return $this->respond([ - 'status' => 'success', - 'message' => 'save success' - ]); - } catch (\Exception $e) { - return $this->failServerError('Something went wrong: ' . $e->getMessage()); - } - } - - public function saveMonthly() - { - $input = $this->request->getJSON(true); - - try { - $controlId = $input['controlId'] ?? 0; - $yearMonth = $input['yearMonth'] ?? ''; - $operation = $input['operation'] ?? 'replace'; - $tests = $input['tests'] ?? []; - $results = []; - $statistics = []; - $validations = []; - - foreach ($tests as $testData) { - $testId = $testData['testId'] ?? 0; - $resvalues = $testData['resvalue'] ?? []; - $rescomments = $testData['rescomment'] ?? []; - - $controlTest = $this->controlTestModel->getByControlAndTest($controlId, $testId); - $mean = $controlTest['mean'] ?? 0; - $sd = $controlTest['sd'] ?? 0; - $sdLimit = $sd > 0 ? $sd * 2 : 0; - - $testValues = []; - $validCount = 0; - $validSum = 0; - $validSqSum = 0; - - foreach ($resvalues as $day => $value) { - if (!empty($value)) { - $resdate = $yearMonth . '-' . str_pad($day, 2, '0', STR_PAD_LEFT); - $rescomment = $rescomments[$day] ?? ''; - - $resultData = [ - 'control_ref_id' => $controlId, - 'test_ref_id' => $testId, - 'resdate' => $resdate, - 'resvalue' => $value, - 'rescomment' => $rescomment, - ]; - - if ($operation === 'replace') { - $this->resultModel->saveResult($resultData); - } else { - $existing = $this->resultModel->checkExisting($controlId, $testId, $resultData['resdate']); - if (!$existing) { - $this->resultModel->saveResult($resultData); - } - } - - $numValue = (float) $value; - $testValues[] = $numValue; - $validCount++; - $validSum += $numValue; - $validSqSum += $numValue * $numValue; - - $withinLimit = true; - if ($sdLimit > 0) { - $withinLimit = abs($numValue - $mean) <= $sdLimit; - } - - if (!$withinLimit) { - $validations[] = [ - 'testId' => $testId, - 'day' => $day, - 'value' => $value, - 'mean' => $mean, - 'sd' => $sd, - 'status' => 'out_of_range' - ]; - } - } - } - - if ($validCount > 0) { - $calcMean = $validSum / $validCount; - $calcSd = 0; - if ($validCount > 1) { - $variance = ($validSqSum - ($validSum * $validSum) / $validCount) / ($validCount - 1); - $calcSd = $variance > 0 ? sqrt($variance) : 0; - } - $cv = $calcMean > 0 ? ($calcSd / $calcMean) * 100 : 0; - - $statistics[] = [ - 'testId' => $testId, - 'n' => $validCount, - 'mean' => round($calcMean, 3), - 'sd' => round($calcSd, 3), - 'cv' => round($cv, 2) - ]; - } - - $results[] = [ - 'testId' => $testId, - 'saved' => count($resvalues) - ]; - } - - return $this->respond([ - 'status' => 'success', - 'message' => 'save success', - 'data' => [ - 'results' => $results, - 'statistics' => $statistics, - 'validations' => $validations - ] - ]); - } catch (\Exception $e) { - return $this->failServerError('Something went wrong: ' . $e->getMessage()); - } - } - - public function saveComment() - { - $input = $this->request->getJSON(true); - - try { - $commentData = [ - 'control_ref_id' => $input['controlId'] ?? 0, - 'test_ref_id' => $input['testId'] ?? 0, - 'commonth' => $input['commonth'] ?? '', - 'comtext' => $input['comtext'] ?? '', - ]; - - $this->commentModel->saveComment($commentData); - return $this->respond([ - 'status' => 'success', - 'message' => 'save success' - ]); - } catch (\Exception $e) { - return $this->failServerError('Something went wrong: ' . $e->getMessage()); - } - } - - public function getMonthlyData() - { - $controlId = $this->request->getGet('controlId'); - $testId = $this->request->getGet('testId'); - $yearMonth = $this->request->getGet('yearMonth'); - - try { - $results = $this->resultModel->getByMonth($controlId, $testId, $yearMonth); - $comment = $this->commentModel->getByControlTestMonth($controlId, $testId, $yearMonth); - - $formValues = []; - $comments = []; - foreach ($results as $row) { - $day = (int)date('j', strtotime($row['resdate'])); - $formValues[$day] = $row['resvalue']; - if (!empty($row['rescomment'])) { - $comments[$day] = $row['rescomment']; - } - } - - return $this->respond([ - 'status' => 'success', - 'message' => 'fetch success', - 'data' => [ - 'formValues' => $formValues, - 'comments' => $comments, - 'comment' => $comment ? $comment['comtext'] : '' - ] - ], 200); - } catch (\Exception $e) { - return $this->failServerError('Something went wrong: ' . $e->getMessage()); - } - } -} diff --git a/app/Controllers/Control.php b/app/Controllers/Control.php deleted file mode 100644 index 0969dc6..0000000 --- a/app/Controllers/Control.php +++ /dev/null @@ -1,36 +0,0 @@ -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' - ]); - } -} diff --git a/app/Controllers/Dashboard.php b/app/Controllers/Dashboard.php deleted file mode 100644 index fec4041..0000000 --- a/app/Controllers/Dashboard.php +++ /dev/null @@ -1,28 +0,0 @@ - $dictDeptModel->findAll(), - 'tests' => $dictTestModel->getWithDept(), - 'controls' => $dictControlModel->getWithDept(), - 'recent_results' => $resultModel->findAll(20), - 'page_title' => 'Dashboard', - 'active_menu' => 'dashboard' - ]); - } -} diff --git a/app/Controllers/Dept.php b/app/Controllers/Dept.php deleted file mode 100644 index ffd0055..0000000 --- a/app/Controllers/Dept.php +++ /dev/null @@ -1,25 +0,0 @@ -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' - ]); - } -} diff --git a/app/Controllers/Entry.php b/app/Controllers/Entry.php deleted file mode 100644 index 5bbce67..0000000 --- a/app/Controllers/Entry.php +++ /dev/null @@ -1,32 +0,0 @@ - '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' - ]); - } -} diff --git a/app/Controllers/Api/TestApiController.php b/app/Controllers/Master/MasterControlsController.php similarity index 52% rename from app/Controllers/Api/TestApiController.php rename to app/Controllers/Master/MasterControlsController.php index 37f0cb1..ef09e7f 100644 --- a/app/Controllers/Api/TestApiController.php +++ b/app/Controllers/Master/MasterControlsController.php @@ -1,46 +1,42 @@ dictTestModel = new DictTestModel(); - $this->dictDeptModel = new DictDeptModel(); + public function __construct() { + $this->model = new MasterControlsModel(); $this->rules = [ 'name' => 'required|min_length[1]', - 'dept_ref_id' => 'required', + 'lot' => 'required|min_length[1]', ]; } - public function index() - { + public function index() { + $keyword = $this->request->getGet('keyword'); try { - $rows = $this->dictTestModel->getWithDept(); + $rows = $this->model->search($keyword); return $this->respond([ 'status' => 'success', 'message' => 'fetch success', 'data' => $rows ], 200); } catch (\Exception $e) { - return $this->failServerError('Exception: ' . $e->getMessage()); + return $this->failServerError($e->getMessage()); } } - public function show($id = null) - { + public function show($id = null) { try { - $rows = $this->dictTestModel->where('test_id', $id)->findAll(); - if (empty($rows)) { + $row = $this->model->find($id); + if (!$row) { return $this->respond([ 'status' => 'success', 'message' => 'data not found.' @@ -49,58 +45,58 @@ class TestApiController extends BaseController return $this->respond([ 'status' => 'success', 'message' => 'fetch success', - 'data' => $rows + 'data' => [$row] ], 200); } catch (\Exception $e) { - return $this->failServerError('Something went wrong: ' . $e->getMessage()); + return $this->failServerError($e->getMessage()); } } - public function create() - { + public function create() { $input = $this->request->getJSON(true); + $input = camel_to_snake_array($input); if (!$this->validate($this->rules)) { return $this->failValidationErrors($this->validator->getErrors()); } try { - $id = $this->dictTestModel->insert($input, true); + $id = $this->model->insert($input, true); return $this->respondCreated([ 'status' => 'success', 'message' => $id ]); } catch (\Exception $e) { - return $this->failServerError('Something went wrong: ' . $e->getMessage()); + return $this->failServerError($e->getMessage()); } } - public function update($id = null) - { + public function update($id = null) { $input = $this->request->getJSON(true); + $input = camel_to_snake_array($input); if (!$this->validate($this->rules)) { return $this->failValidationErrors($this->validator->getErrors()); } try { - $this->dictTestModel->update($id, $input); + $this->model->update($id, $input); return $this->respond([ 'status' => 'success', 'message' => 'update success', - 'data' => $id - ]); + 'data' => [$id] + ], 200); } catch (\Exception $e) { - return $this->failServerError('Something went wrong: ' . $e->getMessage()); + return $this->failServerError($e->getMessage()); } } - public function delete($id = null) - { + public function delete($id = null) { try { - $this->dictTestModel->delete($id); + $this->model->delete($id); return $this->respond([ 'status' => 'success', - 'message' => 'delete success' - ]); + 'message' => 'delete success', + 'data' => [$id] + ], 200); } catch (\Exception $e) { - return $this->failServerError('Something went wrong: ' . $e->getMessage()); + return $this->failServerError($e->getMessage()); } } } diff --git a/app/Controllers/Api/DeptApiController.php b/app/Controllers/Master/MasterDeptsController.php similarity index 54% rename from app/Controllers/Api/DeptApiController.php rename to app/Controllers/Master/MasterDeptsController.php index a7c701d..4fd60ea 100644 --- a/app/Controllers/Api/DeptApiController.php +++ b/app/Controllers/Master/MasterDeptsController.php @@ -1,42 +1,41 @@ dictDeptModel = new DictDeptModel(); + public function __construct() { + $this->model = new MasterDeptsModel(); $this->rules = [ 'name' => 'required|min_length[1]', ]; } - public function index() - { + public function index() { + $keyword = $this->request->getGet('keyword'); try { - $rows = $this->dictDeptModel->findAll(); + $rows = $this->model->search($keyword); return $this->respond([ 'status' => 'success', 'message' => 'fetch success', 'data' => $rows ], 200); } catch (\Exception $e) { - return $this->failServerError('Exception: ' . $e->getMessage()); + return $this->failServerError($e->getMessage()); } } - public function show($id = null) - { + public function show($id = null) { try { - $rows = $this->dictDeptModel->where('dept_id', $id)->findAll(); - if (empty($rows)) { + $row = $this->model->find($id); + if (!$row) { return $this->respond([ 'status' => 'success', 'message' => 'data not found.' @@ -45,58 +44,58 @@ class DeptApiController extends BaseController return $this->respond([ 'status' => 'success', 'message' => 'fetch success', - 'data' => $rows + 'data' => [$row] ], 200); } catch (\Exception $e) { - return $this->failServerError('Something went wrong: ' . $e->getMessage()); + return $this->failServerError($e->getMessage()); } } - public function create() - { + public function create() { $input = $this->request->getJSON(true); + $input = camel_to_snake_array($input); if (!$this->validate($this->rules)) { return $this->failValidationErrors($this->validator->getErrors()); } try { - $id = $this->dictDeptModel->insert($input, true); + $id = $this->model->insert($input, true); return $this->respondCreated([ 'status' => 'success', 'message' => $id ]); } catch (\Exception $e) { - return $this->failServerError('Something went wrong: ' . $e->getMessage()); + return $this->failServerError($e->getMessage()); } } - public function update($id = null) - { + public function update($id = null) { $input = $this->request->getJSON(true); + $input = camel_to_snake_array($input); if (!$this->validate($this->rules)) { return $this->failValidationErrors($this->validator->getErrors()); } try { - $this->dictDeptModel->update($id, $input); + $this->model->update($id, $input); return $this->respond([ 'status' => 'success', 'message' => 'update success', - 'data' => $id - ]); + 'data' => [$id] + ], 200); } catch (\Exception $e) { - return $this->failServerError('Something went wrong: ' . $e->getMessage()); + return $this->failServerError($e->getMessage()); } } - public function delete($id = null) - { + public function delete($id = null) { try { - $this->dictDeptModel->delete($id); + $this->model->delete($id); return $this->respond([ 'status' => 'success', - 'message' => 'delete success' - ]); + 'message' => 'delete success', + 'data' => [$id] + ], 200); } catch (\Exception $e) { - return $this->failServerError('Something went wrong: ' . $e->getMessage()); + return $this->failServerError($e->getMessage()); } } } diff --git a/app/Controllers/Master/MasterTestsController.php b/app/Controllers/Master/MasterTestsController.php new file mode 100644 index 0000000..916c6e8 --- /dev/null +++ b/app/Controllers/Master/MasterTestsController.php @@ -0,0 +1,101 @@ +model = new MasterTestsModel(); + $this->rules = [ + 'name' => 'required|min_length[1]', + ]; + } + + public function index() { + $keyword = $this->request->getGet('keyword'); + try { + $rows = $this->model->search($keyword); + return $this->respond([ + 'status' => 'success', + 'message' => 'fetch success', + 'data' => $rows + ], 200); + } catch (\Exception $e) { + return $this->failServerError($e->getMessage()); + } + } + + public function show($id = null) { + try { + $row = $this->model->find($id); + if (!$row) { + return $this->respond([ + 'status' => 'success', + 'message' => 'data not found.' + ], 200); + } + return $this->respond([ + 'status' => 'success', + 'message' => 'fetch success', + 'data' => [$row] + ], 200); + } catch (\Exception $e) { + return $this->failServerError($e->getMessage()); + } + } + + public function create() { + $input = $this->request->getJSON(true); + $input = camel_to_snake_array($input); + if (!$this->validate($this->rules)) { + return $this->failValidationErrors($this->validator->getErrors()); + } + try { + $id = $this->model->insert($input, true); + return $this->respondCreated([ + 'status' => 'success', + 'message' => $id + ]); + } catch (\Exception $e) { + return $this->failServerError($e->getMessage()); + } + } + + public function update($id = null) { + $input = $this->request->getJSON(true); + $input = camel_to_snake_array($input); + if (!$this->validate($this->rules)) { + return $this->failValidationErrors($this->validator->getErrors()); + } + try { + $this->model->update($id, $input); + return $this->respond([ + 'status' => 'success', + 'message' => 'update success', + 'data' => [$id] + ], 200); + } catch (\Exception $e) { + return $this->failServerError($e->getMessage()); + } + } + + public function delete($id = null) { + try { + $this->model->delete($id); + return $this->respond([ + 'status' => 'success', + 'message' => 'delete success', + 'data' => [$id] + ], 200); + } catch (\Exception $e) { + return $this->failServerError($e->getMessage()); + } + } +} diff --git a/app/Controllers/PageController.php b/app/Controllers/PageController.php index 1f441ca..7991861 100644 --- a/app/Controllers/PageController.php +++ b/app/Controllers/PageController.php @@ -2,157 +2,40 @@ namespace App\Controllers; -class PageController extends BaseController -{ - protected $dictDeptModel; - protected $dictTestModel; - protected $dictControlModel; - protected $resultModel; - protected $controlTestModel; - protected $commentModel; +use CodeIgniter\API\ResponseTrait; - 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(); +class PageController extends BaseController { + use ResponseTrait; + + public function dashboard() { + return view('dashboard'); } - 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 masterDept() { + return view('master/dept/index'); } - public function dept(): string - { - return view('dept/index', [ - 'title' => 'Department Dictionary', - 'depts' => $this->dictDeptModel->findAll(), - 'active_menu' => 'dept', - 'page_title' => 'Department Dictionary' - ]); + public function masterTest() { + return view('master/test/index'); } - 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 masterControl() { + return view('master/control/index'); } - 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() { + return view('entry/index'); } - 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() { + return view('entry/daily'); } - 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() { + return view('report/index'); } - 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' - ]); + public function reportView() { + return view('report/view'); } } diff --git a/app/Controllers/Qc/ControlTestsController.php b/app/Controllers/Qc/ControlTestsController.php new file mode 100644 index 0000000..3b3b1af --- /dev/null +++ b/app/Controllers/Qc/ControlTestsController.php @@ -0,0 +1,99 @@ +model = new ControlTestsModel(); + $this->rules = []; + } + + public function index() { + $keyword = $this->request->getGet('keyword'); + try { + $rows = $this->model->search($keyword); + return $this->respond([ + 'status' => 'success', + 'message' => 'fetch success', + 'data' => $rows + ], 200); + } catch (\Exception $e) { + return $this->failServerError($e->getMessage()); + } + } + + public function show($id = null) { + try { + $row = $this->model->find($id); + if (!$row) { + return $this->respond([ + 'status' => 'success', + 'message' => 'data not found.' + ], 200); + } + return $this->respond([ + 'status' => 'success', + 'message' => 'fetch success', + 'data' => [$row] + ], 200); + } catch (\Exception $e) { + return $this->failServerError($e->getMessage()); + } + } + + public function create() { + $input = $this->request->getJSON(true); + $input = camel_to_snake_array($input); + if (!$this->validate($this->rules)) { + return $this->failValidationErrors($this->validator->getErrors()); + } + try { + $id = $this->model->insert($input, true); + return $this->respondCreated([ + 'status' => 'success', + 'message' => $id + ]); + } catch (\Exception $e) { + return $this->failServerError($e->getMessage()); + } + } + + public function update($id = null) { + $input = $this->request->getJSON(true); + $input = camel_to_snake_array($input); + if (!$this->validate($this->rules)) { + return $this->failValidationErrors($this->validator->getErrors()); + } + try { + $this->model->update($id, $input); + return $this->respond([ + 'status' => 'success', + 'message' => 'update success', + 'data' => [$id] + ], 200); + } catch (\Exception $e) { + return $this->failServerError($e->getMessage()); + } + } + + public function delete($id = null) { + try { + $this->model->delete($id); + return $this->respond([ + 'status' => 'success', + 'message' => 'delete success', + 'data' => [$id] + ], 200); + } catch (\Exception $e) { + return $this->failServerError($e->getMessage()); + } + } +} diff --git a/app/Controllers/Qc/ResultCommentsController.php b/app/Controllers/Qc/ResultCommentsController.php new file mode 100644 index 0000000..1896213 --- /dev/null +++ b/app/Controllers/Qc/ResultCommentsController.php @@ -0,0 +1,99 @@ +model = new ResultCommentsModel(); + $this->rules = []; + } + + public function index() { + $keyword = $this->request->getGet('keyword'); + try { + $rows = $this->model->search($keyword); + return $this->respond([ + 'status' => 'success', + 'message' => 'fetch success', + 'data' => $rows + ], 200); + } catch (\Exception $e) { + return $this->failServerError($e->getMessage()); + } + } + + public function show($id = null) { + try { + $row = $this->model->find($id); + if (!$row) { + return $this->respond([ + 'status' => 'success', + 'message' => 'data not found.' + ], 200); + } + return $this->respond([ + 'status' => 'success', + 'message' => 'fetch success', + 'data' => [$row] + ], 200); + } catch (\Exception $e) { + return $this->failServerError($e->getMessage()); + } + } + + public function create() { + $input = $this->request->getJSON(true); + $input = camel_to_snake_array($input); + if (!$this->validate($this->rules)) { + return $this->failValidationErrors($this->validator->getErrors()); + } + try { + $id = $this->model->insert($input, true); + return $this->respondCreated([ + 'status' => 'success', + 'message' => $id + ]); + } catch (\Exception $e) { + return $this->failServerError($e->getMessage()); + } + } + + public function update($id = null) { + $input = $this->request->getJSON(true); + $input = camel_to_snake_array($input); + if (!$this->validate($this->rules)) { + return $this->failValidationErrors($this->validator->getErrors()); + } + try { + $this->model->update($id, $input); + return $this->respond([ + 'status' => 'success', + 'message' => 'update success', + 'data' => [$id] + ], 200); + } catch (\Exception $e) { + return $this->failServerError($e->getMessage()); + } + } + + public function delete($id = null) { + try { + $this->model->delete($id); + return $this->respond([ + 'status' => 'success', + 'message' => 'delete success', + 'data' => [$id] + ], 200); + } catch (\Exception $e) { + return $this->failServerError($e->getMessage()); + } + } +} diff --git a/app/Controllers/Qc/ResultsController.php b/app/Controllers/Qc/ResultsController.php new file mode 100644 index 0000000..8b0deb8 --- /dev/null +++ b/app/Controllers/Qc/ResultsController.php @@ -0,0 +1,99 @@ +model = new ResultsModel(); + $this->rules = []; + } + + public function index() { + $keyword = $this->request->getGet('keyword'); + try { + $rows = $this->model->search($keyword); + return $this->respond([ + 'status' => 'success', + 'message' => 'fetch success', + 'data' => $rows + ], 200); + } catch (\Exception $e) { + return $this->failServerError($e->getMessage()); + } + } + + public function show($id = null) { + try { + $row = $this->model->find($id); + if (!$row) { + return $this->respond([ + 'status' => 'success', + 'message' => 'data not found.' + ], 200); + } + return $this->respond([ + 'status' => 'success', + 'message' => 'fetch success', + 'data' => [$row] + ], 200); + } catch (\Exception $e) { + return $this->failServerError($e->getMessage()); + } + } + + public function create() { + $input = $this->request->getJSON(true); + $input = camel_to_snake_array($input); + if (!$this->validate($this->rules)) { + return $this->failValidationErrors($this->validator->getErrors()); + } + try { + $id = $this->model->insert($input, true); + return $this->respondCreated([ + 'status' => 'success', + 'message' => $id + ]); + } catch (\Exception $e) { + return $this->failServerError($e->getMessage()); + } + } + + public function update($id = null) { + $input = $this->request->getJSON(true); + $input = camel_to_snake_array($input); + if (!$this->validate($this->rules)) { + return $this->failValidationErrors($this->validator->getErrors()); + } + try { + $this->model->update($id, $input); + return $this->respond([ + 'status' => 'success', + 'message' => 'update success', + 'data' => [$id] + ], 200); + } catch (\Exception $e) { + return $this->failServerError($e->getMessage()); + } + } + + public function delete($id = null) { + try { + $this->model->delete($id); + return $this->respond([ + 'status' => 'success', + 'message' => 'delete success', + 'data' => [$id] + ], 200); + } catch (\Exception $e) { + return $this->failServerError($e->getMessage()); + } + } +} diff --git a/app/Controllers/Report.php b/app/Controllers/Report.php deleted file mode 100644 index 5021bc8..0000000 --- a/app/Controllers/Report.php +++ /dev/null @@ -1,26 +0,0 @@ - 'Reports', - 'depts' => $dictDeptModel->findAll(), - 'tests' => $dictTestModel->findAll(), - 'controls' => $dictControlModel->findAll(), - 'active_menu' => 'report', - 'page_title' => 'Reports' - ]); - } -} diff --git a/app/Controllers/Test.php b/app/Controllers/Test.php deleted file mode 100644 index 0ef1b81..0000000 --- a/app/Controllers/Test.php +++ /dev/null @@ -1,29 +0,0 @@ -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' - ]); - } -} diff --git a/app/Database/Migrations/2026-01-14-000001_CreateCmodQcTables.php b/app/Database/Migrations/2026-01-14-000001_CreateCmodQcTables.php deleted file mode 100644 index ae2c90a..0000000 --- a/app/Database/Migrations/2026-01-14-000001_CreateCmodQcTables.php +++ /dev/null @@ -1,282 +0,0 @@ -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, - ], - 'created_at' => [ - 'type' => 'DATETIME', - 'null' => true, - ], - 'updated_at' => [ - 'type' => 'DATETIME', - 'null' => true, - ], - 'deleted_at' => [ - 'type' => 'DATETIME', - '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, - ], - 'created_at' => [ - 'type' => 'DATETIME', - 'null' => true, - ], - 'updated_at' => [ - 'type' => 'DATETIME', - 'null' => true, - ], - 'deleted_at' => [ - 'type' => 'DATETIME', - '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, - ], - 'created_at' => [ - 'type' => 'DATETIME', - 'null' => true, - ], - 'updated_at' => [ - 'type' => 'DATETIME', - 'null' => true, - ], - 'deleted_at' => [ - 'type' => 'DATETIME', - '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, - ], - 'created_at' => [ - 'type' => 'DATETIME', - 'null' => true, - ], - 'updated_at' => [ - 'type' => 'DATETIME', - 'null' => true, - ], - 'deleted_at' => [ - 'type' => 'DATETIME', - '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, - ], - 'created_at' => [ - 'type' => 'DATETIME', - 'null' => true, - ], - 'updated_at' => [ - 'type' => 'DATETIME', - 'null' => true, - ], - 'deleted_at' => [ - 'type' => 'DATETIME', - '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, - ], - 'created_at' => [ - 'type' => 'DATETIME', - 'null' => true, - ], - 'updated_at' => [ - 'type' => 'DATETIME', - 'null' => true, - ], - 'deleted_at' => [ - 'type' => 'DATETIME', - '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'); - } -} diff --git a/app/Database/Migrations/2026-01-17-000001-QualityControlSystem.php b/app/Database/Migrations/2026-01-17-000001-QualityControlSystem.php new file mode 100644 index 0000000..cd5a9bf --- /dev/null +++ b/app/Database/Migrations/2026-01-17-000001-QualityControlSystem.php @@ -0,0 +1,107 @@ +forge->addField([ + 'dept_id' => ['type' => 'INT', 'unsigned' => true, 'auto_increment' => true], + 'name' => ['type' => 'VARCHAR', 'constraint' => 50, 'null' => true], + 'created_at' => ['type' => 'DATETIME', 'null' => true], + 'updated_at' => ['type' => 'DATETIME', 'null' => true], + 'deleted_at' => ['type' => 'DATETIME', 'null' => true], + ]); + $this->forge->addKey('dept_id', true); + $this->forge->createTable('dict_depts'); + + $this->forge->addField([ + 'control_id' => ['type' => 'INT', 'unsigned' => true, 'auto_increment' => true], + 'dept_id' => ['type' => 'INT', 'unsigned' => true, 'null' => true], + 'name' => ['type' => 'VARCHAR', 'constraint' => 50, 'null' => true], + 'lot' => ['type' => 'VARCHAR', 'constraint' => 50, 'null' => true], + 'producer' => ['type' => 'TEXT', 'null' => true], + 'exp_date' => ['type' => 'DATE', 'null' => true], + 'created_at' => ['type' => 'DATETIME', 'null' => true], + 'updated_at' => ['type' => 'DATETIME', 'null' => true], + 'deleted_at' => ['type' => 'DATETIME', 'null' => true], + ]); + $this->forge->addKey('control_id', true); + $this->forge->addForeignKey('dept_id', 'dict_depts', 'dept_id', 'SET NULL', 'CASCADE'); + $this->forge->createTable('dict_controls'); + + $this->forge->addField([ + 'test_id' => ['type' => 'INT', 'unsigned' => true, 'auto_increment' => true], + 'dept_id' => ['type' => 'INT', 'unsigned' => true, '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], + 'created_at' => ['type' => 'DATETIME', 'null' => true], + 'updated_at' => ['type' => 'DATETIME', 'null' => true], + 'deleted_at' => ['type' => 'DATETIME', 'null' => true], + ]); + $this->forge->addKey('test_id', true); + $this->forge->addForeignKey('dept_id', 'dict_depts', 'dept_id', 'SET NULL', 'CASCADE'); + $this->forge->createTable('dict_tests'); + + $this->forge->addField([ + 'control_test_id' => ['type' => 'INT', 'unsigned' => true, 'auto_increment' => true], + 'control_id' => ['type' => 'INT', 'unsigned' => true, 'null' => true], + 'test_id' => ['type' => 'INT', 'unsigned' => true, 'null' => true], + 'mean' => ['type' => 'FLOAT', 'null' => true], + 'sd' => ['type' => 'FLOAT', 'null' => true], + 'created_at' => ['type' => 'DATETIME', 'null' => true], + 'updated_at' => ['type' => 'DATETIME', 'null' => true], + 'deleted_at' => ['type' => 'DATETIME', 'null' => true], + ]); + $this->forge->addKey('control_test_id', true); + $this->forge->addForeignKey('control_id', 'dict_controls', 'control_id', 'SET NULL', 'CASCADE'); + $this->forge->addForeignKey('test_id', 'dict_tests', 'test_id', 'SET NULL', 'CASCADE'); + $this->forge->createTable('control_tests'); + + $this->forge->addField([ + 'result_id' => ['type' => 'INT', 'unsigned' => true, 'auto_increment' => true], + 'control_id' => ['type' => 'INT', 'unsigned' => true, 'null' => true], + 'test_id' => ['type' => 'INT', 'unsigned' => true, 'null' => true], + 'res_date' => ['type' => 'DATETIME', 'null' => true], + 'res_value' => ['type' => 'VARCHAR', 'constraint' => 50, 'null' => true], + 'res_comment' => ['type' => 'TEXT', 'null' => true], + 'created_at' => ['type' => 'DATETIME', 'null' => true], + 'updated_at' => ['type' => 'DATETIME', 'null' => true], + 'deleted_at' => ['type' => 'DATETIME', 'null' => true], + ]); + $this->forge->addKey('result_id', true); + $this->forge->addForeignKey('control_id', 'dict_controls', 'control_id', 'SET NULL', 'CASCADE'); + $this->forge->addForeignKey('test_id', 'dict_tests', 'test_id', 'SET NULL', 'CASCADE'); + $this->forge->createTable('results'); + + $this->forge->addField([ + 'result_comment_id' => ['type' => 'INT', 'unsigned' => true, 'auto_increment' => true], + 'control_id' => ['type' => 'INT', 'unsigned' => true], + 'test_id' => ['type' => 'INT', 'unsigned' => true], + 'comment_month' => ['type' => 'VARCHAR', 'constraint' => 7], + 'com_text' => ['type' => 'TEXT', 'null' => true], + 'created_at' => ['type' => 'DATETIME', 'null' => true], + 'updated_at' => ['type' => 'DATETIME', 'null' => true], + 'deleted_at' => ['type' => 'DATETIME', 'null' => true], + ]); + $this->forge->addKey('result_comment_id', true); + $this->forge->addUniqueKey(['control_id', 'test_id', 'comment_month']); + $this->forge->addForeignKey('control_id', 'dict_controls', 'control_id', 'CASCADE', 'CASCADE'); + $this->forge->addForeignKey('test_id', 'dict_tests', 'test_id', 'CASCADE', 'CASCADE'); + $this->forge->createTable('result_comments'); + } + + public function down() { + $this->forge->dropTable('result_comments', true); + $this->forge->dropTable('results', true); + $this->forge->dropTable('control_tests', true); + $this->forge->dropTable('dict_tests', true); + $this->forge->dropTable('dict_controls', true); + $this->forge->dropTable('dict_depts', true); + } +} diff --git a/app/Database/Migrations/2026-01-18-000001-QualityControlSystem.php b/app/Database/Migrations/2026-01-18-000001-QualityControlSystem.php new file mode 100644 index 0000000..500f7c6 --- /dev/null +++ b/app/Database/Migrations/2026-01-18-000001-QualityControlSystem.php @@ -0,0 +1,110 @@ +forge->addField([ + 'dept_id' => ['type' => 'INT', 'unsigned' => true, 'auto_increment' => true], + 'name' => ['type' => 'VARCHAR', 'constraint' => 50, 'null' => true], + 'created_at' => ['type' => 'DATETIME', 'null' => true], + 'updated_at' => ['type' => 'DATETIME', 'null' => true], + 'deleted_at' => ['type' => 'DATETIME', 'null' => true], + ]); + $this->forge->addKey('dept_id', true); + $this->forge->createTable('master_depts'); + + $this->forge->addField([ + 'control_id' => ['type' => 'INT', 'unsigned' => true, 'auto_increment' => true], + 'dept_id' => ['type' => 'INT', 'unsigned' => true, 'null' => true], + 'name' => ['type' => 'VARCHAR', 'constraint' => 50, 'null' => true], + 'lot' => ['type' => 'VARCHAR', 'constraint' => 50, 'null' => true], + 'producer' => ['type' => 'TEXT', 'null' => true], + 'exp_date' => ['type' => 'DATE', 'null' => true], + 'created_at' => ['type' => 'DATETIME', 'null' => true], + 'updated_at' => ['type' => 'DATETIME', 'null' => true], + 'deleted_at' => ['type' => 'DATETIME', 'null' => true], + ]); + $this->forge->addKey('control_id', true); + $this->forge->addForeignKey('dept_id', 'master_depts', 'dept_id', 'SET NULL', 'CASCADE'); + $this->forge->createTable('master_controls'); + + $this->forge->addField([ + 'test_id' => ['type' => 'INT', 'unsigned' => true, 'auto_increment' => true], + 'dept_id' => ['type' => 'INT', 'unsigned' => true, '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], + 'created_at' => ['type' => 'DATETIME', 'null' => true], + 'updated_at' => ['type' => 'DATETIME', 'null' => true], + 'deleted_at' => ['type' => 'DATETIME', 'null' => true], + ]); + $this->forge->addKey('test_id', true); + $this->forge->addForeignKey('dept_id', 'master_depts', 'dept_id', 'SET NULL', 'CASCADE'); + $this->forge->createTable('master_tests'); + + $this->forge->addField([ + 'control_test_id' => ['type' => 'INT', 'unsigned' => true, 'auto_increment' => true], + 'control_id' => ['type' => 'INT', 'unsigned' => true, 'null' => true], + 'test_id' => ['type' => 'INT', 'unsigned' => true, 'null' => true], + 'mean' => ['type' => 'FLOAT', 'null' => true], + 'sd' => ['type' => 'FLOAT', 'null' => true], + 'created_at' => ['type' => 'DATETIME', 'null' => true], + 'updated_at' => ['type' => 'DATETIME', 'null' => true], + 'deleted_at' => ['type' => 'DATETIME', 'null' => true], + ]); + $this->forge->addKey('control_test_id', true); + $this->forge->addForeignKey('control_id', 'master_controls', 'control_id', 'SET NULL', 'CASCADE'); + $this->forge->addForeignKey('test_id', 'master_tests', 'test_id', 'SET NULL', 'CASCADE'); + $this->forge->createTable('control_tests'); + + $this->forge->addField([ + 'result_id' => ['type' => 'INT', 'unsigned' => true, 'auto_increment' => true], + 'control_id' => ['type' => 'INT', 'unsigned' => true, 'null' => true], + 'test_id' => ['type' => 'INT', 'unsigned' => true, 'null' => true], + 'res_date' => ['type' => 'DATETIME', 'null' => true], + 'res_value' => ['type' => 'VARCHAR', 'constraint' => 50, 'null' => true], + 'res_comment' => ['type' => 'TEXT', 'null' => true], + 'created_at' => ['type' => 'DATETIME', 'null' => true], + 'updated_at' => ['type' => 'DATETIME', 'null' => true], + 'deleted_at' => ['type' => 'DATETIME', 'null' => true], + ]); + $this->forge->addKey('result_id', true); + $this->forge->addForeignKey('control_id', 'master_controls', 'control_id', 'SET NULL', 'CASCADE'); + $this->forge->addForeignKey('test_id', 'master_tests', 'test_id', 'SET NULL', 'CASCADE'); + $this->forge->createTable('results'); + + $this->forge->addField([ + 'result_comment_id' => ['type' => 'INT', 'unsigned' => true, 'auto_increment' => true], + 'control_id' => ['type' => 'INT', 'unsigned' => true], + 'test_id' => ['type' => 'INT', 'unsigned' => true], + 'comment_month' => ['type' => 'VARCHAR', 'constraint' => 7], + 'com_text' => ['type' => 'TEXT', 'null' => true], + 'created_at' => ['type' => 'DATETIME', 'null' => true], + 'updated_at' => ['type' => 'DATETIME', 'null' => true], + 'deleted_at' => ['type' => 'DATETIME', 'null' => true], + ]); + $this->forge->addKey('result_comment_id', true); + $this->forge->addUniqueKey(['control_id', 'test_id', 'comment_month']); + $this->forge->addForeignKey('control_id', 'master_controls', 'control_id', 'CASCADE', 'CASCADE'); + $this->forge->addForeignKey('test_id', 'master_tests', 'test_id', 'CASCADE', 'CASCADE'); + $this->forge->createTable('result_comments'); + } + + public function down() + { + $this->forge->dropTable('result_comments', true); + $this->forge->dropTable('results', true); + $this->forge->dropTable('control_tests', true); + $this->forge->dropTable('master_tests', true); + $this->forge->dropTable('master_controls', true); + $this->forge->dropTable('master_depts', true); + } +} diff --git a/app/Database/Migrations/2026-01-18-000001-RenameDictToMasterTables.php b/app/Database/Migrations/2026-01-18-000001-RenameDictToMasterTables.php new file mode 100644 index 0000000..3bac25e --- /dev/null +++ b/app/Database/Migrations/2026-01-18-000001-RenameDictToMasterTables.php @@ -0,0 +1,45 @@ +query('SET FOREIGN_KEY_CHECKS=0'); + + $tables = $db->listTables(); + if (in_array('dict_depts', $tables)) { + $db->query('RENAME TABLE dict_depts TO master_depts'); + } + if (in_array('dict_controls', $tables)) { + $db->query('RENAME TABLE dict_controls TO master_controls'); + } + if (in_array('dict_tests', $tables)) { + $db->query('RENAME TABLE dict_tests TO master_tests'); + } + + $db->query('SET FOREIGN_KEY_CHECKS=1'); + } + + public function down() { + $db = \Config\Database::connect(); + + $db->query('SET FOREIGN_KEY_CHECKS=0'); + + $tables = $db->listTables(); + if (in_array('master_depts', $tables)) { + $db->query('RENAME TABLE master_depts TO dict_depts'); + } + if (in_array('master_controls', $tables)) { + $db->query('RENAME TABLE master_controls TO dict_controls'); + } + if (in_array('master_tests', $tables)) { + $db->query('RENAME TABLE master_tests TO dict_tests'); + } + + $db->query('SET FOREIGN_KEY_CHECKS=1'); + } +} diff --git a/app/Database/Migrations/test.php b/app/Database/Migrations/test.php new file mode 100644 index 0000000..1bfd141 --- /dev/null +++ b/app/Database/Migrations/test.php @@ -0,0 +1,10 @@ +query("SELECT * FROM migrations")->getResult(); +print_r($results); + +echo "\nChecking for dict_ tables:\n"; +$tables = $db->listTables(); +print_r($tables); diff --git a/app/Database/Seeds/CmodQcSeeder.php b/app/Database/Seeds/CmodQcSeeder.php deleted file mode 100644 index c0cbdfd..0000000 --- a/app/Database/Seeds/CmodQcSeeder.php +++ /dev/null @@ -1,322 +0,0 @@ - 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); - } -} diff --git a/app/Models/ControlModel.php b/app/Models/ControlModel.php deleted file mode 100644 index 3aec9bd..0000000 --- a/app/Models/ControlModel.php +++ /dev/null @@ -1,41 +0,0 @@ -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(); - } -} diff --git a/app/Models/ControlTestModel.php b/app/Models/ControlTestModel.php deleted file mode 100644 index 7ba7530..0000000 --- a/app/Models/ControlTestModel.php +++ /dev/null @@ -1,32 +0,0 @@ -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(); - } -} diff --git a/app/Models/DailyResultModel.php b/app/Models/DailyResultModel.php deleted file mode 100644 index 323634e..0000000 --- a/app/Models/DailyResultModel.php +++ /dev/null @@ -1,61 +0,0 @@ -db->table('daily_result'); - $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('daily_result'); - $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('daily_result'); - $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('daily_result_id', $existing['daily_result_id'])->update($data); - } else { - return $builder->insert($data); - } - } -} diff --git a/app/Models/DeptModel.php b/app/Models/DeptModel.php deleted file mode 100644 index 02351b0..0000000 --- a/app/Models/DeptModel.php +++ /dev/null @@ -1,16 +0,0 @@ -where('dept_ref_id', $deptId)->findAll(); - } - - public function getWithDept($keyword = null, $deptId = null) - { - $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'); - - if ($keyword) { - $builder->groupStart(); - $builder->like('c.name', $keyword); - $builder->orLike('c.lot', $keyword); - $builder->groupEnd(); - } - - if ($deptId) { - $builder->where('c.dept_ref_id', $deptId); - } - - 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(); - } -} diff --git a/app/Models/DictDeptModel.php b/app/Models/DictDeptModel.php deleted file mode 100644 index d5bd067..0000000 --- a/app/Models/DictDeptModel.php +++ /dev/null @@ -1,16 +0,0 @@ -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(); - } -} diff --git a/app/Models/Master/MasterControlsModel.php b/app/Models/Master/MasterControlsModel.php new file mode 100644 index 0000000..ba73971 --- /dev/null +++ b/app/Models/Master/MasterControlsModel.php @@ -0,0 +1,32 @@ +groupStart() + ->like('name', $keyword) + ->orLike('lot', $keyword) + ->groupEnd() + ->findAll(); + } + return $this->findAll(); + } +} diff --git a/app/Models/Master/MasterDeptsModel.php b/app/Models/Master/MasterDeptsModel.php new file mode 100644 index 0000000..5e2a300 --- /dev/null +++ b/app/Models/Master/MasterDeptsModel.php @@ -0,0 +1,27 @@ +groupStart() + ->like('name', $keyword) + ->groupEnd() + ->findAll(); + } + return $this->findAll(); + } +} diff --git a/app/Models/Master/MasterTestsModel.php b/app/Models/Master/MasterTestsModel.php new file mode 100644 index 0000000..e692759 --- /dev/null +++ b/app/Models/Master/MasterTestsModel.php @@ -0,0 +1,33 @@ +groupStart() + ->like('name', $keyword) + ->groupEnd() + ->findAll(); + } + return $this->findAll(); + } +} diff --git a/app/Models/MonthlyCommentModel.php b/app/Models/MonthlyCommentModel.php deleted file mode 100644 index cf8c2b1..0000000 --- a/app/Models/MonthlyCommentModel.php +++ /dev/null @@ -1,38 +0,0 @@ -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['monthly_comment_id'], $data); - } else { - return $this->insert($data); - } - } -} diff --git a/app/Models/Qc/ControlTestsModel.php b/app/Models/Qc/ControlTestsModel.php new file mode 100644 index 0000000..e15abdc --- /dev/null +++ b/app/Models/Qc/ControlTestsModel.php @@ -0,0 +1,30 @@ +groupStart() + ->like('mean', $keyword) + ->groupEnd() + ->findAll(); + } + return $this->findAll(); + } +} diff --git a/app/Models/Qc/ResultCommentsModel.php b/app/Models/Qc/ResultCommentsModel.php new file mode 100644 index 0000000..d602de0 --- /dev/null +++ b/app/Models/Qc/ResultCommentsModel.php @@ -0,0 +1,31 @@ +groupStart() + ->like('comment_month', $keyword) + ->orLike('com_text', $keyword) + ->groupEnd() + ->findAll(); + } + return $this->findAll(); + } +} diff --git a/app/Models/Qc/ResultsModel.php b/app/Models/Qc/ResultsModel.php new file mode 100644 index 0000000..50943aa --- /dev/null +++ b/app/Models/Qc/ResultsModel.php @@ -0,0 +1,31 @@ +groupStart() + ->like('res_value', $keyword) + ->groupEnd() + ->findAll(); + } + return $this->findAll(); + } +} diff --git a/app/Models/ResultCommentModel.php b/app/Models/ResultCommentModel.php deleted file mode 100644 index d4086be..0000000 --- a/app/Models/ResultCommentModel.php +++ /dev/null @@ -1,38 +0,0 @@ -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); - } - } -} diff --git a/app/Models/ResultModel.php b/app/Models/ResultModel.php deleted file mode 100644 index 9bb70a9..0000000 --- a/app/Models/ResultModel.php +++ /dev/null @@ -1,72 +0,0 @@ -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); - } - } - - public function checkExisting($controlId, $testId, $resdate) - { - $builder = $this->db->table('results'); - return $builder->select('result_id') - ->where('control_ref_id', $controlId) - ->where('test_ref_id', $testId) - ->where('resdate', $resdate) - ->get() - ->getRowArray(); - } -} diff --git a/app/Models/TestModel.php b/app/Models/TestModel.php deleted file mode 100644 index 2897ab7..0000000 --- a/app/Models/TestModel.php +++ /dev/null @@ -1,29 +0,0 @@ -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(); - } -} diff --git a/app/Views/control/dialog_form.php b/app/Views/control/dialog_form.php deleted file mode 100644 index 2ee4847..0000000 --- a/app/Views/control/dialog_form.php +++ /dev/null @@ -1,95 +0,0 @@ - -
Manage control materials and lot numbers
-Loading controls...
-No controls found
-| # | -Name | -Lot | -Department | -Status | -Expiry Date | -Actions | -
|---|---|---|---|---|---|---|
| - | - | - - | -- | - - | -- | - - - | -
Total Tests
-Total Controls
-Quality Control Overview
+Departments
-Total Controls
+24
Quick access to all features
+ +Tests Today
+156
+Manage test types, methods, and units
-Manage control materials and lot numbers
-Manage departments and units
-Enter monthly QC results
-Enter daily QC results
-View and generate QC reports
-Pass Rate
+98.5%
+Alerts
+3
+Dashboard content coming soon...
+Manage department entries
-Loading departments...
-No departments found
-| # | -Name | -Actions | -
|---|---|---|
| - | - | - - - | -
Enter daily QC results
-Record daily QC test results
Daily entry form coming soon...
Record quality control results
+Record daily QC test results
+Monthly QC analysis & comments
+Enter monthly QC results
-| Test | - -- - | - -
|---|---|
| - - | - -
-
-
-
-
-
-
-
- |
-
-
Select one or more tests above to view and enter monthly data
-Select a control to view available tests
-