tinyqc/v1/inc/entry_ajax.php
mahdahar ff90e0eb29 Initial commit: Add CodeIgniter 4 QC application with full MVC structure
- CodeIgniter 4 framework setup with SQL Server database config
- Models: Control, Test, Dept, Result, Daily/ Monthly entry models
- Controllers: Dashboard, Control, Test, Dept, Entry, Report, API endpoints
- Views: CRUD pages with modal dialogs, dashboard, reports
- Database: Migrations for control test and daily/monthly result tables
- Legacy v1 PHP application preserved in /v1 directory
- Documentation: AGENTS.md, VIEWS_RULES.md for development guidelines
2026-01-14 16:49:27 +07:00

51 lines
1.4 KiB
PHP

<?php
include '../config.php';
// Read POST data
$postData = json_decode(file_get_contents("php://input"));
$request = "";
if(isset($postData->request)){
$request = $postData->request;
}
// Get Test
if($request == 'getTest'){
$result = array();$data = array();
if(isset($postData->control)){
$control = $postData->control;
$sql = "select dt.id, dt.name from CONTROL_TEST ct left join DICT_TEST dt on dt.id=ct.testid where ct.controlid='$control'";
$stmt = sqlsrv_query( $conn1, $sql );
if( $stmt == false) { die( print_r( sqlsrv_errors(), true) ); }
while ( $row = sqlsrv_fetch_array( $stmt, SQLSRV_FETCH_NUMERIC ) ) {
$id = $row[0];
$name = $row[1];
$data[] = array( "id" => $id, "name" => $name );
}
}
echo json_encode($data);
die;
}
// Get Control
elseif($request == 'getControl'){
$result = array();$data = array();
if(isset($postData->dates)){
$dates = $postData->dates;
$dept = $postData->dept;
$sql = "select id, name, lot from DICT_CONTROL where expdate > '$dates' and deptID='$dept'";
$stmt = sqlsrv_query( $conn1, $sql );
if( $stmt == false) { die( print_r( sqlsrv_errors(), true) ); }
while ( $row = sqlsrv_fetch_array( $stmt, SQLSRV_FETCH_NUMERIC ) ) {
$id = $row[0];
$name = $row[1];
$lot = $row[2];
$data[] = array( "id" => $id, "name" => "$name - $lot" );
}
}
echo json_encode($data);
die;
}