-
Notifications
You must be signed in to change notification settings - Fork 0
/
new_vehicle.php
111 lines (103 loc) · 3.34 KB
/
new_vehicle.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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
<?php
include 'core/core.inc.php';
if (!isset($_SESSION['user_id'])) {
header("Location: login.php");
}
$message = false;
include 'core/user.db.php';
if (isset($_POST['submit'])) {
if (empty($_POST['veichle_type'])) {
$message = 'Invalid vehicle type.';
}elseif (empty($_POST['veichle_subtype'])) {
$message = 'Invalid subtype.';
}elseif (empty($_POST['veichle_driver'])) {
$message = "No Driver assigned.";
}elseif (empty($_POST['veichle_number'])) {
$message = 'Vehicle number is empty.';
}else{
include_once 'core/vehicle.db.php';
$a = new Vehicle($host, $db_name, $db_user, $db_pass);
if(!$a->insert($_POST['veichle_type'], $_POST['veichle_subtype'], $_POST['veichle_driver'], $_POST['veichle_number'], $_POST['location'])){
$message = "Vehicle already exist.";
}
}
}
$u = new User($host, $db_name, $db_user, $db_pass);
$all_driver = $u->getDriver();
?>
<!DOCTYPE html>
<html>
<head>
<title>Dashboard</title>
<meta name="og:title" property="og:title" content="TATA Sponge Limited :: History"/>
<?php
include 'core/meta.php';
?>
<link rel="stylesheet" href="css/core.css">
</head>
<body>
<?php
require "core/top_nav.php";
?>
<div class="container-fluid">
<div class="row">
<div class="col col-lg-3 side_nav">
<?php
$active = "vehicle";
require "core/side_nav.php";
?>
</div>
<div class="col-md-9">
<br><br>
<form class="needs-validation" novalidate method="POST">
<div class="form-row">
<div class="form-group col-md-4">
<label for="veichle_type">Vehicle Type</label>
<select name="veichle_type" class="form-control" id="veichle_type" >
<option></option>
<option>Auto</option>
<option>Bus</option>
<option>Van</option>
<option>Car</option>
<option>Truck</option>
<option>Pickup Truck</option>
</select>
</div>
<div class="form-group col-md-4">
<label for="veichle_subtype">Sub type</label>
<input type="text" name="veichle_subtype" class="form-control" id="veichle_subtype" value="" placeholder="TATA Sumo, Marcopolo etc">
</div>
<div class="form-group col-md-4">
<label for="veichle_driver">Driver</label>
<select name="veichle_driver" class="form-control" id="veichle_driver" >
<?php foreach ($all_driver as $key => $value): ?>
<option value="<?=$value['id'];?>"><?=$value['name'];?></option>
<?php endforeach ?>
</select>
</div>
</div>
<div class="form-row">
<div class="form-group col-md-4">
<label for="veichle_number">Vehicle Number</label>
<input type="text" name="veichle_number" class="form-control" id="veichle_number" value="" placeholder="JH05ACXXXX">
</div>
<div class="form-group col-md-4">
<label for="location">Current Location</label>
<input type="text" name="location" class="form-control" id="location" value="" placeholder="Car Shade">
</div>
</div>
<button type="reset" class="btn btn-danger">Reset</button>
<button type="submit" name="submit" class="btn btn-primary">Save</button>
<br><br>
</form>
</div>
</div>
</div>
</body>
<?php include_once 'core/basic_java.inc.php'; ?>
<script type="text/javascript">
<?php if ($message): ?>
swal({dangerMode:true,title:"<?=$message;?>"});
<?php endif ?>
</script>
</html>