This repository has been archived by the owner on Oct 21, 2023. It is now read-only.
/
transport.php
88 lines (70 loc) · 2.05 KB
/
transport.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
<?php
require_once 'functions.php';
$id = (int)$_GET['id'];
if ($_GET['delete']) {
$delete = (int)$_GET['delete'];
$db->query("UPDATE transport_options SET active = 0 WHERE id = $delete LIMIT 1");
$print = "Option was deleted";
}
if ($_POST) {
$post = array(
'name' => html($_POST['name']),
);
if ($id) {
$db->update("transport_options",$post,"id = $id");
} else {
$db->insert("transport_options",$post);
$id = $db->insert_id;
}
header("Location: " . URL . "info/transport/saved");
exit();
}
$list = $db->query("SELECT * FROM transport_options WHERE active = 1 ORDER BY id");
if ($id) {
$info = $db->query("SELECT * FROM transport_options WHERE id = $id");
}
if ($_GET['saved']) {
$print = "Information has been saved";
}
?>
<!doctype html>
<html>
<head>
<title><?php echo SITENAME ?></title>
<?php echo $head ?>
</head>
<body>
<?php require_once 'include.header.php'; ?>
<?php if ($print) { echo "<div class=\"alert alert-success\">$print</div>"; } ?>
<h1>Transport Options</h1>
<table class="table table-striped">
<tr>
<th>Name</th>
<th>Edit</th>
<th>Delete</th>
</tr>
<?php while ($row = $list->fetch()) { ?>
<tr>
<td><?php echo $row['name'] ?></td>
<td><a href="edit/transport/<?php echo $row['id'] ?>">Edit</a></td>
<td><a href="transport.php?delete=<?php echo $row['id'] ?>" onclick="javascript:return confirm('Are you sure?')">Delete</a></td>
</tr>
<?php $area[$row['id']] = $row['name']; } ?>
</table>
<h1><?php echo $id ? 'Edit' : 'Add' ?> Transport Option</h1>
<form method="post" class="form form-horizontal">
<div class="form-group">
<label class="col-sm-2 control-label">Name</label>
<div class="col-sm-10">
<input type="text" class="form-control" name="name" value="<?php echo $info->name ?>" />
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<button type="submit" class="btn btn-primary">Save</button>
</div>
</div>
</form>
<?php require_once 'include.footer.php'; ?>
</body>
</html>