-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathssuccess.js
224 lines (188 loc) · 9.31 KB
/
ssuccess.js
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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
// Simple login functionality
const loginForm = document.getElementById('loginForm');
loginForm.addEventListener('submit', function(event) {
event.preventDefault();
const username = document.getElementById('username').value;
const password = document.getElementById('password').value;
// Simple credential check (replace with a real authentication mechanism)
if (username === 'admin' && password === 'password') {
document.getElementById('loginPage').classList.add('hidden');
document.getElementById('tableNamesPage').classList.remove('hidden');
} else {
alert('Invalid credentials');
}
});
// Function to show specific pages
function showPage(pageId) {
const pages = document.querySelectorAll('div[id$="Page"]');
pages.forEach(page => page.classList.add('hidden'));
document.getElementById(pageId).classList.remove('hidden');
}
// Functions to add new records and manage tables (Transport example)
const transportForm = document.getElementById('transportForm');
const transportTable = document.getElementById('transportTable').getElementsByTagName('tbody')[0];
transportForm.addEventListener('submit', function(event) {
event.preventDefault();
const vehicleId = document.getElementById('vehicleId').value;
const licensePlate = document.getElementById('licensePlate').value;
const model = document.getElementById('model').value;
const capacities = document.getElementById('capacities').value;
const status = document.getElementById('status').value;
const newRow = transportTable.insertRow();
newRow.insertCell(0).textContent = vehicleId;
newRow.insertCell(1).textContent = licensePlate;
newRow.insertCell(2).textContent = model;
newRow.insertCell(3).textContent = capacities;
newRow.insertCell(4).textContent = status;
const actionsCell = newRow.insertCell(5);
const deleteButton = document.createElement('button');
deleteButton.textContent = 'Delete';
deleteButton.addEventListener('click', function() {
transportTable.deleteRow(newRow.rowIndex - 1);
});
actionsCell.appendChild(deleteButton);
transportForm.reset();
});
// Driver form functionality
const driverForm = document.getElementById('driverForm');
const driverTable = document.getElementById('driverTable').getElementsByTagName('tbody')[0];
driverForm.addEventListener('submit', function(event) {
event.preventDefault();
const driverId = document.getElementById('driverId').value;
const dname = document.getElementById('dname').value;
const licenseNumber = document.getElementById('licenseNumber').value;
const contactInfo = document.getElementById('contactInfo').value;
const newRow = driverTable.insertRow();
newRow.insertCell(0).textContent = driverId;
newRow.insertCell(1).textContent = dname;
newRow.insertCell(2).textContent = licenseNumber;
newRow.insertCell(3).textContent = contactInfo;
const actionsCell = newRow.insertCell(4);
const deleteButton = document.createElement('button');
deleteButton.textContent = 'Delete';
deleteButton.addEventListener('click', function() {
driverTable.deleteRow(newRow.rowIndex - 1);
});
actionsCell.appendChild(deleteButton);
driverForm.reset();
});
// Route form functionality
const routeForm = document.getElementById('routeForm');
const routeTable = document.getElementById('routeTable').getElementsByTagName('tbody')[0];
routeForm.addEventListener('submit', function(event) {
event.preventDefault();
const routeId = document.getElementById('routeId').value;
const origin = document.getElementById('origin').value;
const destination = document.getElementById('destination').value;
const distance = document.getElementById('distance').value;
const newRow = routeTable.insertRow();
newRow.insertCell(0).textContent = routeId;
newRow.insertCell(1).textContent = origin;
newRow.insertCell(2).textContent = destination;
newRow.insertCell(3).textContent = distance;
const actionsCell = newRow.insertCell(4);
const deleteButton = document.createElement('button');
deleteButton.textContent = 'Delete';
deleteButton.addEventListener('click', function() {
routeTable.deleteRow(newRow.rowIndex - 1);
});
actionsCell.appendChild(deleteButton);
routeForm.reset();
});
// Assignment form functionality
const assignmentForm = document.getElementById('assignmentForm');
const assignmentTable = document.getElementById('assignmentTable').getElementsByTagName('tbody')[0];
assignmentForm.addEventListener('submit', function(event) {
event.preventDefault();
const assignmentId = document.getElementById('assignmentId').value;
const transportId = document.getElementById('transportId').value;
const driverId = document.getElementById('driverId').value;
const routeId = document.getElementById('routeId').value;
const startDate = document.getElementById('startDate').value;
const newRow = assignmentTable.insertRow();
newRow.insertCell(0).textContent = assignmentId;
newRow.insertCell(1).textContent = transportId;
newRow.insertCell(2).textContent = driverId;
newRow.insertCell(3).textContent = routeId;
newRow.insertCell(4).textContent = startDate;
const actionsCell = newRow.insertCell(5);
const deleteButton = document.createElement('button');
deleteButton.textContent = 'Delete';
deleteButton.addEventListener('click', function() {
assignmentTable.deleteRow(newRow.rowIndex - 1);
});
actionsCell.appendChild(deleteButton);
assignmentForm.reset();
});
// Tracking record form functionality
const trackingForm = document.getElementById('trackingForm');
const trackingTable = document.getElementById('trackingTable').getElementsByTagName('tbody')[0];
trackingForm.addEventListener('submit', function(event) {
event.preventDefault();
const trackingId = document.getElementById('trackingId').value;
const shipmentId = document.getElementById('trackingShipmentId').value;
const location = document.getElementById('trackingLocation').value;
const status = document.getElementById('trackingStatus').value;
const timestamp = document.getElementById('trackingTimestamp').value;
const newRow = trackingTable.insertRow();
newRow.insertCell(0).textContent = trackingId;
newRow.insertCell(1).textContent = shipmentId;
newRow.insertCell(2).textContent = location;
newRow.insertCell(3).textContent = status;
newRow.insertCell(4).textContent = timestamp;
const actionsCell = newRow.insertCell(5);
const deleteButton = document.createElement('button');
deleteButton.textContent = 'Delete';
deleteButton.addEventListener('click', function() {
trackingTable.deleteRow(newRow.rowIndex - 1);
});
actionsCell.appendChild(deleteButton);
trackingForm.reset();
});
//customer details
const customerForm = document.getElementById('customerForm');
const customerTable = document.getElementById('customerTable').getElementsByTagName('tbody')[0];
customerForm.addEventListener('submit', function(event) {
event.preventDefault();
const customerId = document.getElementById('customerId').value;
const cname = document.getElementById('cname').value;
const contactDetails = document.getElementById('contactDetails').value;
const newRow = customerTable.insertRow();
newRow.insertCell(0).textContent = customerId;
newRow.insertCell(1).textContent = cname;
newRow.insertCell(2).textContent = contactDetails;
const actionsCell = newRow.insertCell(3);
const deleteButton = document.createElement('button');
deleteButton.textContent = 'Delete';
deleteButton.addEventListener('click', function() {
customerTable.deleteRow(newRow.rowIndex - 1);
});
actionsCell.appendChild(deleteButton);
customerForm.reset();
});
// Shipment record form functionality
const shipmentForm = document.getElementById('shipmentForm');
const shipmentTable = document.getElementById('shipmentTable').getElementsByTagName('tbody')[0];
shipmentForm.addEventListener('submit', function(event) {
event.preventDefault();
const shipmentId = document.getElementById('shipmentId').value;
const origin = document.getElementById('origin').value;
const destination = document.getElementById('destination').value;
const weight = document.getElementById('weight').value;
const status = document.getElementById('status').value;
const newRow = shipmentTable.insertRow();
newRow.insertCell(0).textContent = shipmentId;
newRow.insertCell(1).textContent = origin;
newRow.insertCell(2).textContent = destination;
newRow.insertCell(3).textContent = weight;
newRow.insertCell(4).textContent = status;
const actionsCell = newRow.insertCell(5);
const deleteButton = document.createElement('button');
deleteButton.textContent = 'Delete';
deleteButton.addEventListener('click', function() {
shipmentTable.deleteRow(newRow.rowIndex - 1);
});
actionsCell.appendChild(deleteButton);
shipmentForm.reset();
});
// Similar functions can be created for other forms and tables