trip plan developed

parent bc440486
images/
\ No newline at end of file
...@@ -212,6 +212,21 @@ ...@@ -212,6 +212,21 @@
<?php <?php
$all_station_id_list = array();
for($d = $start_location; $d >= $last_railway_stop; $d--) {
$sql15 = "SELECT * FROM visitplacetemp WHERE placeTrainNo = '$d' AND logUserid = $logUserid ";
$result15 = mysqli_query($con,$sql15) or die(mysqli_error($con));
$rowcount15 = mysqli_num_rows($result15);
$row15 = mysqli_fetch_assoc($result15);
if($rowcount15 > 0){
$station_id = $row15['placeTrainNo'];
array_push($all_station_id_list, $station_id);
}
}
$array_call_count = 1;
for($c = $start_location; $c >= $last_railway_stop; $c--) { for($c = $start_location; $c >= $last_railway_stop; $c--) {
$sql15 = "SELECT * FROM visitplacetemp WHERE placeTrainNo = '$c' AND logUserid = $logUserid "; $sql15 = "SELECT * FROM visitplacetemp WHERE placeTrainNo = '$c' AND logUserid = $logUserid ";
...@@ -407,11 +422,46 @@ ...@@ -407,11 +422,46 @@
if($specific_station_train_no_count > 0) { if($specific_station_train_no_count > 0) {
$specific_train_id = $specific_station_train_no[0]; $specific_train_id = $specific_station_train_no[0];
} }
$all_station_id_list_count = count($all_station_id_list);
if($all_station_id_list_count > $array_call_count){
$next_specific_location = $all_station_id_list[$array_call_count];
} else if($all_station_id_list_count == $array_call_count) {
break;
}
$sql16 = "SELECT * FROM train_times WHERE `id` = $specific_train_id ";
$result16 = mysqli_query($con,$sql16) or die(mysqli_error($con));
$row16 = mysqli_fetch_assoc($result16);
$middle_train_arrival_time = $row16['arrival'];
$middle_train_dep_time = $row16['dep'];
$middle_train_name = $row16['trainname']; //Train name
$middle_train_arrival_time_trim = trim($middle_train_arrival_time);
$middle_train_dep_time_trim = trim($middle_train_dep_time);
$middle_train_arrival_date_time = $separate_date ." ".$middle_train_arrival_time_trim; // Arrival
$middle_train_dep_date_time = $separate_date ." ".$middle_train_dep_time_trim; //Departure
$start_date_time = $middle_train_dep_date_time;
$sql18 = "SELECT * FROM final_railway_station WHERE train_no = $next_specific_location AND `line` = $now_line_no ";
$result18 = mysqli_query($con,$sql18) or die(mysqli_error($con));
$row18 = mysqli_fetch_assoc($result18);
$middle_to_next_station_name = $row18['name']; //Station Name
?>
<td> <?php echo $middle_train_name ?> </td>
<td> <?php echo str_replace(' ', '<br>', $middle_train_arrival_date_time) ?> </td>
<td> <?php echo $middle_to_next_station_name ?> </td>
<td> <?php echo str_replace(' ', '<br>', $middle_train_dep_date_time) ?> </td>
<?php
$array_call_count++;
}else { }else {
continue; continue;
} }
......
<?php
for($c = $start_location; $c >= $last_railway_stop; $c--) {
$sql15 = "SELECT * FROM visitplacetemp WHERE placeTrainNo = '$c' ";
$result15 = mysqli_query($con,$sql15) or die(mysqli_error($con));
$rowcount5 = mysqli_num_rows($result15);
echo $c;
if($rowcount5 > 0 || $c == $start_location){
$sql13 = "SELECT * FROM `train_times` WHERE `lineno` = '$now_line_no' AND `trainno` = '$c' AND dirId ='f' ORDER BY `arrival` ASC";
$result13 = mysqli_query($con,$sql13) or die(mysqli_error($con));
$all_times = array();
while($row13 = mysqli_fetch_array($result13)) {
$time_arrival = $row13['arrival'];
$train_id = $row13['id'];
$time_arrival = strtotime($time_arrival);
$start_time = strtotime($start_time);
if($time_arrival > $start_time){
array_push($all_times,$train_id);
}
}
if(count($all_times) > 0){
$get_best_train_id = $all_times[0];
}
$sql14 = "SELECT * FROM `train_times` WHERE id = '$get_best_train_id' ";
$result14 = mysqli_query($con,$sql14) or die(mysqli_error($con));
$row14 = mysqli_fetch_assoc($result14);
$train_start_location = $c; //Start
$tra_train_name = $row14['trainname']; // Train Name
$tra_train_arrival = $row14['arrival']; // Arrival
$tra_train_dep = $row14['dep']; // Departure
$train_current_location = $row14['trainno'];
$sql17 = "SELECT * FROM final_railway_station WHERE `line` = $now_line_no AND `train_no` = $train_start_location ";
$result17 = mysqli_query($con,$sql17) or die(mysqli_error($con));
$row17 = mysqli_fetch_assoc($result17);
$to_station = $row17['to_train_no'];
$sql18 = "SELECT * FROM final_railway_station WHERE `line` = $now_line_no AND `train_no` = $to_station ";
$result18 = mysqli_query($con,$sql18) or die(mysqli_error($con));
$row18 = mysqli_fetch_assoc($result18);
if($to_station == 0) {
$end_location = 'Colombo Fort';
} else {
$end_location = $row18['name'];
}
$start_time = $tra_train_dep;
?>
<tr>
<td> <?php echo $row17['name'] ?> </td>
<td> <?php echo $tra_train_name ?> </td>
<td>08/25/2021 <br> <?php echo $tra_train_arrival ?> </td>
<td> <?php echo $end_location ?> </td>
<td>08/25/2021 <br> <?php echo $tra_train_dep ?></td>
<td>
<?php
if($c == $start_location) {
} else {
?>
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#exampleModal<?php echo $c ?>">
Locations
</button>
<?php
}
?>
<div class="modal fade" id="exampleModal<?php echo $c ?>" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog modal-lg" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel">Location List</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body">
<table class="table table-bordered">
<thead class="thead-light">
<tr>
<th>Location</th>
<th scope="col">Category</th>
<th scope="col">Estimate Time</th>
<th scope="col">Google Map</th>
</tr>
</thead>
<tbody>
<?php
if($c != $start_location) {
$sql16 = "SELECT * FROM visitplacetemp WHERE placeLineNo = '$now_line_no' AND placeTrainNo = '$c' ";
$result16 = mysqli_query($con,$sql16) or die(mysqli_error($con));
$all_es_time = 0;
while($row16 = mysqli_fetch_array($result16)) {
$final_place_id = $row16['placeId'];
$sql19 = "SELECT * FROM places WHERE id = '$final_place_id' ";
$result19 = mysqli_query($con,$sql19) or die(mysqli_error($con));
$row19 = mysqli_fetch_assoc($result19);
$final_category_id = $row19['category_id'];
$sql20 = "SELECT * FROM category WHERE id = '$final_category_id' ";
$result20 = mysqli_query($con,$sql20) or die(mysqli_error($con));
$row20 = mysqli_fetch_assoc($result20);
$single_es_time = $row20['eTime'];
$all_es_time = $all_es_time + $single_es_time;
?>
<tr>
<td> <?php echo $row19['place_name'] ?> </td>
<td> <?php echo $row20['name'] ?> </td>
<td> <?php echo $row20['eTime'] . " Hours" ?></td>
<td>
<button class="btn btn-primary"> Map <i class="fa fa-map-marker" style="font-size:18px; margin-left: 3%;"></i></button></td>
</tr>
<?php
}
$all_time_stand = "+".$all_es_time." hours";
$now_date = date('H:i:s', strtotime($start_time . $all_time_stand));
// $enddate = strtotime($all_time_stand, $start_time);
}
?>
</tbody>
</table>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-danger" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
</td>
</tr>
<?php
if($c != $start_location){
$start_date = '24:00:00';
} else {
$start_date = '24:00:00';
}
} else {
continue;
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment