-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsubmitorder.php
More file actions
48 lines (41 loc) · 1.76 KB
/
submitorder.php
File metadata and controls
48 lines (41 loc) · 1.76 KB
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
<?php
$servername = "localhost";
$username = "admin";
$password = "admin";
$dbname = "woodysdb";
$vin = $_POST["vin"];
$date = $_POST["date"];
$location = $_POST["location"];
$vehicle_type = $_POST["vehicle_type"];
$skill_names = $_POST["skill"];
$cust_id = $_POST["cust_id"];
$conn = new mysqli($servername, $username, $password, $dbname);
$display_order_query = "SELECT `id`, `svc_type`, `vehicle_type`, `skill_id`, `price` FROM `servicesoffered` WHERE `svc_type` = \"$skill_names\" AND `vehicle_type` = \"$vehicle_type\"";
$get_loc_id = "SELECT `id` FROM `businesslocation` WHERE `loc_address` = \"$location\"";
$loc_id = $conn->query($get_loc_id);
$loc_id = $loc_id->fetch_assoc()["id"];
$services = $conn->query($display_order_query);
$base_price = 0;
$row = $services->fetch_assoc();
$service_id = $row["id"];
echo "Vehicle Type Is: ".$row["vehicle_type"];
echo "<br>You ordered the following service: ";
echo "Service: ".$row["svc_type"]." | Price: ". $row["price"];
$base_price = $base_price + $row["price"];
echo "<br>Your base price is: $".$base_price. " Labor is not included.";
echo "<br>Appointment date: " . $date;
echo "<br><a href=\"index.php\">Return</a>";
$appt_insert = "INSERT INTO `appointment` (`appt_date`, `loc_id`, `cust_id`, `vin`)
VALUES ($date, $loc_id, $cust_id, $vin)";
$conn->query($appt_insert);
$appt_id = $conn->insert_id;
$appt_date_update = "UPDATE `appointment` SET appt_date = '$date' WHERE id = $appt_id";
$conn->query($appt_date_update);
$inv_insert = "INSERT INTO `invoice` (`amount`)
VALUES ($base_price)";
$conn->query($inv_insert);
$inv_id = $conn->insert_id;
$invdetails_insert = "INSERT INTO `invoicedetails` (`appt_id`, `service_id`, `invoice_id`, `price`)
VALUES ($appt_id, $service_id, $inv_id, $base_price)";
$conn->query($invdetails_insert);
?>