tinyqc/v1/inc/ct_view.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

64 lines
2.1 KiB
PHP

<?php
$cid = $_GET['cid'];
$sql = "select name, lot, expdate from DICT_CONTROL where id='$cid'";
$stmt = sqlsrv_query( $conn1, $sql );
if( $stmt == false) { die( print_r( sqlsrv_errors(), true) ); }
$row = sqlsrv_fetch_array( $stmt, SQLSRV_FETCH_NUMERIC );
$cname = $row[0];
$lot = $row[1];
if($row[2]!='') { $expdate = date_format($row[2],"d-m-Y"); }
else { $expdate = ''; }
if(isset($_POST['add'])) {
if(isset($_POST['test'])) {
$testid = $_POST['test'];
$mean = $_POST['mean'];
$sd = $_POST['sd'];
$sql = "INSERT INTO CONTROL_TEST (testid,controlid,mean,sd) VALUES ('$testid','$cid','$mean','$sd')";
$stmt = sqlsrv_query( $conn1, $sql );
if( $stmt == false) { die( print_r( sqlsrv_errors(), true) ); }
}
}
?>
Control <?php echo $cname; ?><br/>
Lot <?php echo $lot; ?><br/>
Exp date <?php echo $expdate; ?><br/>
<table border='1'>
<tr><th>no</th><th>test</th><th>mean</th><th>sd</th></tr>
<tr>
<form method='POST'>
<td></td>
<td><select name='test'>
<?php
$sql = "select id, name from DICT_TEST
where id not in (select testid from CONTROL_TEST where controlid='$cid')";
$stmt = sqlsrv_query( $conn1, $sql );
if( $stmt == false) { die( print_r( sqlsrv_errors(), true) ); }
while( $row = sqlsrv_fetch_array( $stmt, SQLSRV_FETCH_NUMERIC) ) {
$tid = $row[0];
$tname = $row[1];
echo "<option value='$tid'>$tname</option>";
}
?>
</select></td>
<td><input type='text' name='mean' /></td>
<td><input type='text' name='sd' /></td>
<td><input type='submit' value='+' name='add' /></td>
</form>
</tr>
<?php
$sql = "select ct.id, dt.name, ct.mean, ct.sd from DICT_TEST dt, CONTROL_TEST ct
where ct.testid=dt.id and ct.controlid='$cid'";
$stmt = sqlsrv_query( $conn1, $sql );
if( $stmt == false) { die( print_r( sqlsrv_errors(), true) ); }
$i=1;
while( $row = sqlsrv_fetch_array( $stmt, SQLSRV_FETCH_NUMERIC) ) {
$ctid = $row[0];
$tname = $row[1];
$tmean = $row[2];
$tsd = $row[3];
echo "<tr> <td>$i</td> <td>$tname</td> <td>$tmean</td> <td>$tsd</td>
<td> <a href='?p=ct&d=edit&ctid=$ctid&cid=$cid'>edit</a> - <a href='?p=ct&d=del&ctid=$ctid&cid=$cid'>delete</a> </td> </tr>";
$i++;
}
?>
</table>