Mantis-v0.0.3
This commit is contained in:
parent
bb70c85b30
commit
761c9a942b
14
add_bug.php
14
add_bug.php
@ -2,12 +2,18 @@
|
||||
require_once 'db/config.php';
|
||||
|
||||
$title = $description = $steps_to_reproduce = '';
|
||||
$test_case_id = null;
|
||||
$errors = [];
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'GET' && isset($_GET['test_case_id'])) {
|
||||
$test_case_id = (int)$_GET['test_case_id'];
|
||||
}
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
$title = trim($_POST['title'] ?? '');
|
||||
$description = trim($_POST['description'] ?? '');
|
||||
$steps_to_reproduce = trim($_POST['steps_to_reproduce'] ?? '');
|
||||
$test_case_id = isset($_POST['test_case_id']) ? (int)$_POST['test_case_id'] : null;
|
||||
|
||||
if (empty($title)) {
|
||||
$errors[] = 'Title is required.';
|
||||
@ -16,8 +22,9 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
if (empty($errors)) {
|
||||
try {
|
||||
$pdo = db();
|
||||
$stmt = $pdo->prepare('INSERT INTO bugs (title, description, steps_to_reproduce) VALUES (?, ?, ?)');
|
||||
$stmt->execute([$title, $description, $steps_to_reproduce]);
|
||||
$sql = 'INSERT INTO bugs (title, description, steps_to_reproduce, test_case_id) VALUES (?, ?, ?, ?)';
|
||||
$stmt = $pdo->prepare($sql);
|
||||
$stmt->execute([$title, $description, $steps_to_reproduce, $test_case_id]);
|
||||
header('Location: bugs.php');
|
||||
exit;
|
||||
} catch (PDOException $e) {
|
||||
@ -52,6 +59,9 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<form action="add_bug.php" method="POST">
|
||||
<?php if ($test_case_id): ?>
|
||||
<input type="hidden" name="test_case_id" value="<?php echo $test_case_id; ">
|
||||
<?php endif; ?>
|
||||
<div class="mb-3">
|
||||
<label for="title" class="form-label">Title</label>
|
||||
<input type="text" class="form-control" id="title" name="title" value="<?php echo htmlspecialchars($title); ?>" required>
|
||||
|
||||
@ -48,12 +48,33 @@ $test_cases = $stmt->fetchAll();
|
||||
<?php foreach ($test_cases as $test_case): ?>
|
||||
<tr>
|
||||
<td><?php echo htmlspecialchars($test_case['title']); ?></td>
|
||||
<td><span class="badge bg-secondary"><?php echo htmlspecialchars($test_case['status']); ?></span></td>
|
||||
<td>
|
||||
<?php
|
||||
$status_color = 'secondary';
|
||||
switch ($test_case['status']) {
|
||||
case 'Passed':
|
||||
$status_color = 'success';
|
||||
break;
|
||||
case 'Failed':
|
||||
$status_color = 'danger';
|
||||
break;
|
||||
case 'Blocked':
|
||||
$status_color = 'warning';
|
||||
break;
|
||||
}
|
||||
?>
|
||||
<span class="badge bg-<?php echo $status_color; ?>"><?php echo htmlspecialchars($test_case['status']); ?></span>
|
||||
</td>
|
||||
<td><?php echo htmlspecialchars($test_case['created_at']); ?></td>
|
||||
<td>
|
||||
<a href="#" class="btn btn-sm btn-outline-secondary d-inline-flex align-items-center">
|
||||
<i data-feather="eye" class="me-2"></i>View
|
||||
<a href="#" class="btn btn-sm btn-outline-secondary d-inline-flex align-items-center me-2">
|
||||
<i data-feather="eye" class="me-1"></i>View
|
||||
</a>
|
||||
<?php if ($test_case['status'] === 'Failed'): ?>
|
||||
<a href="add_bug.php?test_case_id=<?php echo $test_case['id']; ?>" class="btn btn-sm btn-danger d-inline-flex align-items-center me-2">
|
||||
<i data-feather="plus" class="me-1"></i>Add Bug
|
||||
</a>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user