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

72 lines
2.2 KiB
PHP

<?php
if(!isset($_POST['submit'])) {
$tid = $_GET['tid'];
$tname = '';
$cva = '';
$ba = '';
$tea = '';
$unit = '';
$method = '';
$deptid = '';
if($tid != 0) {
$sql = "select name, cva, ba, tea, unit, method, deptid from DICT_TEST where id='$tid'";
$stmt = sqlsrv_query( $conn1, $sql );
if( $stmt == false) { die( print_r( sqlsrv_errors(), true) ); }
$row = sqlsrv_fetch_array( $stmt, SQLSRV_FETCH_NUMERIC);
$tname = $row[0];
$cva = $row[1];
$ba = $row[2];
$tea = $row[3];
$unit = $row[4];
$method = $row[5];
$deptid = $row[6];
}
$sql = "select id, name from DICT_DEPT";
$stmt = sqlsrv_query( $conn1, $sql );
while($row=sqlsrv_fetch_array( $stmt, SQLSRV_FETCH_NUMERIC)) {
$depts[$row[0]] = $row[1];
}
?>
<form method='POST'>
Dept.<br/>
<select name='deptid'>
<option value=''></option>
<?php
foreach($depts as $qdeptid => $qdeptname) {
echo "<option value='$qdeptid'>$qdeptname</option>";
}
?>
</select>
<br/>
Name<br/>
<input type='text' name='tname' value='<?php echo $tname;?>' /><br/>
Unit<br/>
<input type='text' name='unit' value='<?php echo $unit;?>' /><br/>
Method<br/>
<input type='text' name='method' value='<?php echo $method;?>' /><br/>
CVA<br/>
<input type='text' name='cva' value='<?php echo $cva;?>' /><br/>
BA<br/>
<input type='text' name='ba' value='<?php echo $ba;?>' /><br/>
TEA<br/>
<input type='text' name='tea' value='<?php echo $tea;?>' /><br/>
<input type='hidden' name='tid' value='<?php echo $tid;?>' /><br/>
<input type='submit' name='submit' value='update' />
</form>
<?php
} else {
$tid=$_POST['tid'];
$tname=stripslashes($_POST['tname']);
$deptid = $_POST['deptid'];
$method = $_POST['method'];
$unit = $_POST['unit'];
$cva = $_POST['cva'];
$ba = $_POST['ba'];
$tea = $_POST['tea'];
if($tid != 0) { $sql="UPDATE DICT_TEST SET name='$tname', cva='$cva', ba='$ba', tea='$tea', method='$method', unit='$unit', deptid='$deptid' WHERE id='$tid'"; }
else { $sql="INSERT INTO DICT_TEST(name, method, unit, cva, ba, tea, deptid) values ('$testname', '$method', '$unit', '$cva', '$ba', '$tea', '$deptid')"; }
$stmt=sqlsrv_query( $conn1, $sql );
if($stmt==false) { die( print_r( sqlsrv_errors(), true) ); }
echo "<meta http-equiv='refresh' content='0;url=?p=test' />";
}
?>