Commit e81406de authored by Mihiranga G.L.V - IT18500790's avatar Mihiranga G.L.V - IT18500790

Merge branch 'IT18500790' into 'master'

Finish Create trip plan

See merge request !9
parents 6941d901 2d01e32f
images/36972092396_312b70283e_k.jpg

1.02 MB | W: | H:

images/36972092396_312b70283e_k.jpg

1.02 MB | W: | H:

images/36972092396_312b70283e_k.jpg
images/36972092396_312b70283e_k.jpg
images/36972092396_312b70283e_k.jpg
images/36972092396_312b70283e_k.jpg
  • 2-up
  • Swipe
  • Onion skin
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
// Date count // Date count
$date_count = (int) $days + 1; $date_count = (int) $days + 1;
$full_hours = $date_count * 8; $full_hours = $date_count * 10;
$line_no = array(); $line_no = array();
$sql2 = "SELECT * FROM linelist WHERE logUserid = '$logUserid' ORDER BY id "; $sql2 = "SELECT * FROM linelist WHERE logUserid = '$logUserid' ORDER BY id ";
...@@ -192,7 +192,7 @@ ...@@ -192,7 +192,7 @@
$start_date = $ini_start_date; $start_date = $ini_start_date;
$end_date = $ini_end_date; $end_date = $ini_end_date;
$start_time = '05:00:00'; $start_time = '06:00:00';
$start_date_time = $ini_start_date ." ". $start_time; $start_date_time = $ini_start_date ." ". $start_time;
?> ?>
...@@ -288,7 +288,7 @@ ...@@ -288,7 +288,7 @@
<tr> <tr>
<td> <?php echo $colombo_name ?> </td> <td> <?php echo $colombo_name ?> </td>
<td></td> <td></td>
<td> <?php echo $colombo_train_name ?> </td> <td align="center"> <?php echo $colombo_train_name ?> <br> <img class="animate__animated animate__slow animate__slideInLeft animate__infinite infinite" src="images/green_arrow.png" style="width:30px;" alt=""> </td>
<td> <?php echo str_replace(' ', '<br>', $colombo_train_arrival_date_time) ?> </td> <td> <?php echo str_replace(' ', '<br>', $colombo_train_arrival_date_time) ?> </td>
<td> <?php echo $colombo_to_next_station_name ?> </td> <td> <?php echo $colombo_to_next_station_name ?> </td>
<td> <?php echo str_replace(' ', '<br>', $colombo_train_dep_date_time) ?> </td> <td> <?php echo str_replace(' ', '<br>', $colombo_train_dep_date_time) ?> </td>
...@@ -337,12 +337,31 @@ ...@@ -337,12 +337,31 @@
$sql19 = "SELECT * FROM visitplacetemp WHERE placeLineNo = $now_line_no AND placeTrainNo = '$c' AND logUserid = $logUserid "; $sql19 = "SELECT * FROM visitplacetemp WHERE placeLineNo = $now_line_no AND placeTrainNo = '$c' AND logUserid = $logUserid ";
$result19 = mysqli_query($con,$sql19) or die(mysqli_error($con)); $result19 = mysqli_query($con,$sql19) or die(mysqli_error($con));
$full_time_to_visit = 0;
while($row19 = mysqli_fetch_array($result19)){ while($row19 = mysqli_fetch_array($result19)){
$station_near_by_place_id = $row19['placeId']; $station_near_by_place_id = $row19['placeId'];
$station_near_by_cat_id = $row19['placeCatId']; $station_near_by_cat_id = $row19['placeCatId'];
$station_near_by_es_time = $row19['placeEsTime']; $station_near_by_es_time = $row19['placeEsTime'];
$full_time_to_visit = $full_time_to_visit + $station_near_by_es_time; $start_date_time_array = explode(" ", $start_date_time);
$start_date_only = $start_date_time_array[0];
$start_time_only = $start_date_time_array[1];
$station_near_by_es_time_new = "+".$station_near_by_es_time." hour";
$max_time = "18:00:00";
$start_time_only_new = date('H:i:s', strtotime($start_time_only.$station_near_by_es_time_new));
$start_date_only_new = $start_date_only;
$start_time_only_new_str = strtotime($start_time_only_new);
$max_time_str = strtotime($max_time);
if($start_time_only_new_str > $max_time_str) {
$start_time_only_new = "06:00:00";
$start_date_only_new = date('Y-m-d', strtotime($start_date_time.'+1 day'));
}
$start_date_time = $start_date_only_new." ".$start_time_only_new;
$sql20 = "SELECT * FROM places WHERE id = $station_near_by_place_id "; $sql20 = "SELECT * FROM places WHERE id = $station_near_by_place_id ";
$result20 = mysqli_query($con,$sql20) or die(mysqli_error($con)); $result20 = mysqli_query($con,$sql20) or die(mysqli_error($con));
...@@ -363,7 +382,8 @@ ...@@ -363,7 +382,8 @@
<td> <?php echo $station_near_by_cat_name ?> </td> <td> <?php echo $station_near_by_cat_name ?> </td>
<td> <?php echo $station_near_by_es_time . " Hours" ?></td> <td> <?php echo $station_near_by_es_time . " Hours" ?></td>
<td> <td>
<button class="btn btn-primary"> Map <i class="fa fa-map-marker" style="font-size:18px; margin-left: 3%;"></i></button></td> <button class="btn btn-primary"> Map <i class="fa fa-map-marker" style="font-size:18px; margin-left: 3%;"></i></button
></td>
</tr> </tr>
<?php <?php
...@@ -385,82 +405,162 @@ ...@@ -385,82 +405,162 @@
</div> </div>
</td> </td>
<?php <?php
$full_time_to_visit_hour = "+".$full_time_to_visit." hour"; // echo $start_date_time .'<br>';
$start_date_time_array_after_trip = explode(" ", $start_date_time);
$start_date_after_trip = $start_date_time_array_after_trip[0];
$start_time_after_trip = $start_date_time_array_after_trip[1];
$start_date_time = date('Y-m-d H:i:s', strtotime($start_date_time. $full_time_to_visit_hour)); $max_time_after_trip = "18:00:00";
$separate_date_time = explode(" ", $start_date_time); $start_time_after_trip_str = strtotime($start_time_after_trip);
$separate_date = $separate_date_time[0]; $max_time_after_trip_str = strtotime($max_time_after_trip);
$separate_time = $separate_date_time[1];
$max_time = '18:00:00';
$separate_time_str = strtotime($separate_time); $sql22 = "SELECT * FROM train_times WHERE `lineno` = $now_line_no AND `trainno` = $c AND dirId = 'f' AND CAST(arrival as time) >= '06:00:00' AND CAST(arrival as time) < '18:00:00' ORDER BY arrival ";
$max_time_str = strtotime($max_time); $result22 = mysqli_query($con,$sql22) or die(mysqli_error($con));
$after_trip_train_id_list = array();
$after_trip_train_id_list_sp = array();
while($row22 = mysqli_fetch_assoc($result22)){
$after_trip_train_name = $row22['trainname'];
$after_trip_train_arrival = $row22['arrival'];
$after_trip_train_dep = $row22['dep'];
$after_trip_train_id = $row22['id'];
$after_trip_train_arrival_str = strtotime($after_trip_train_arrival);
if($after_trip_train_arrival_str > $start_time_after_trip_str) {
array_push($after_trip_train_id_list,$after_trip_train_id);
}
array_push($after_trip_train_id_list_sp,$after_trip_train_id);
if($separate_time_str > $max_time_str) {
$separate_date = date('Y-m-d', strtotime($separate_date. '+1 day'));
$separate_time = '05:00:00';
} }
$sql22 = "SELECT * FROM train_times WHERE `lineno` = $now_line_no AND `trainno` = $c AND `dirId` = 'f' ORDER BY `arrival` ASC"; if (empty($after_trip_train_id_list)) {
$result22 = mysqli_query($con,$sql22) or die(mysqli_error($con)); $start_time_after_trip = "06:00:00";
$specific_station_train_no = array(); $start_date_after_trip = date('Y-m-d', strtotime($start_date_time.'+1 day'));
while($row22 = mysqli_fetch_array($result22)){ }
$specific_start_time = $row22['arrival'];
$specific_train_id = $row22['id']; // print_r($after_trip_train_id_list);
$str_sec_start_time = strtotime($separate_time); // print_r($after_trip_train_id_list_sp);
$str_sec_specific_start_time = strtotime($specific_start_time);
// echo $c;
if($str_sec_start_time < $str_sec_specific_start_time) { $this_station_count = count($all_station_id_list);
array_push($specific_station_train_no,$specific_train_id); $this_location_index = array_search($c, $all_station_id_list);
$next_location_index = $this_location_index + 1;
if($this_station_count > $next_location_index) {
$next_location_station = $all_station_id_list[$next_location_index];
if (!empty($after_trip_train_id_list)) {
$selected_train_id = $after_trip_train_id_list[0];
} else {
$selected_train_id = $after_trip_train_id_list_sp[0];
}
$sql23 = "SELECT * FROM train_times WHERE id = $selected_train_id ";
$result23 = mysqli_query($con,$sql23) or die(mysqli_error($con));
$row23 = mysqli_fetch_assoc($result23);
$final_train_name = $row23['trainname']; // Train name
$final_train_arrival = $row23['arrival'];
$final_train_dep = $row23['dep'];
$final_train_arrival = trim($final_train_arrival);
$final_train_dep = trim($final_train_dep);
$final_date_and_time = explode(" ", $start_date_time);
$final_now_date = $final_date_and_time[0];
$final_now_time = $final_date_and_time[1];
$final_train_arrival_date_and_time = $final_now_date ." ".$final_train_arrival; // Train Arrival
$final_train_dep_date_and_time = $final_now_date ." ".$final_train_dep; // Train Depature
$sql24 = "SELECT * FROM final_railway_station WHERE `line` = $now_line_no AND `train_no` = $next_location_station ";
$result24 = mysqli_query($con,$sql24) or die(mysqli_error($con));
$row24 = mysqli_fetch_assoc($result24);
$next_railway_location_name = $row24['name']; // next location name
?>
<td align="center"> <?php echo $final_train_name ?> <br> <img class="animate__animated animate__slow animate__slideInLeft animate__infinite infinite" src="images/green_arrow.png" style="width:30px;" alt=""> </td>
<td> <?php echo str_replace(' ', '<br>', $final_train_arrival_date_and_time) ?> </td>
<td> <?php echo $next_railway_location_name ?> </td>
<td> <?php echo str_replace(' ', '<br>', $final_train_dep_date_and_time) ?> </td>
<?php
$start_date_time = $final_train_dep_date_and_time;
} else if($this_station_count == $next_location_index) {
// echo "eq";
if (empty($after_trip_train_id_list)) {
$selected_train_id = "";
} }
$end_date_and_time = explode(" ", $start_date_time);
$end_now_date = $end_date_and_time[0];
$end_now_time = $end_date_and_time[1];
$end_now_time_str = strtotime($end_now_time);
$sql25 = "SELECT * FROM train_times WHERE lineno = $now_line_no AND trainno = $c AND dirId = 'b' ORDER BY arrival";
$result25 = mysqli_query($con,$sql25) or die(mysqli_error($con));
$end_trip_train_id_list = array();
$end_trip_train_id_list_sp = array();
while($row25 = mysqli_fetch_assoc($result25)){
$end_trip_train_name = $row25['trainname'];
$end_trip_train_arrival = $row25['arrival'];
$end_trip_train_dep = $row25['dep'];
$end_trip_train_id = $row25['id'];
$end_trip_train_arrival_str = strtotime($end_trip_train_arrival);
if($end_trip_train_arrival_str > $end_now_time_str) {
array_push($end_trip_train_id_list,$end_trip_train_id);
} }
$specific_station_train_no_count = count($specific_station_train_no); array_push($end_trip_train_id_list_sp,$end_trip_train_id);
if($specific_station_train_no_count > 0) {
$specific_train_id = $specific_station_train_no[0];
} }
$all_station_id_list_count = count($all_station_id_list); if (empty($end_trip_train_id_list)) {
if($all_station_id_list_count > $array_call_count){ $end_now_time = "06:00:00";
$next_specific_location = $all_station_id_list[$array_call_count]; $end_now_date = date('Y-m-d', strtotime($start_date_time.'+1 day'));
} else if($all_station_id_list_count == $array_call_count) {
break;
} }
if (!empty($end_trip_train_id_list)) {
$end_selected_train_id = $end_trip_train_id_list[0];
} else {
$end_selected_train_id = $end_trip_train_id_list_sp[0];
}
$sql16 = "SELECT * FROM train_times WHERE `id` = $specific_train_id "; $sql26 = "SELECT * FROM train_times WHERE id = $end_selected_train_id ";
$result16 = mysqli_query($con,$sql16) or die(mysqli_error($con)); $result26 = mysqli_query($con,$sql26) or die(mysqli_error($con));
$row16 = mysqli_fetch_assoc($result16); $row26 = mysqli_fetch_assoc($result26);
$middle_train_arrival_time = $row16['arrival']; $end_train_name = $row26['trainname']; // Train name
$middle_train_dep_time = $row16['dep']; $end_train_arrival = $row26['arrival'];
$middle_train_name = $row16['trainname']; //Train name $end_train_dep = $row26['dep'];
$middle_train_arrival_time_trim = trim($middle_train_arrival_time); $end_train_arrival = trim($end_train_arrival);
$middle_train_dep_time_trim = trim($middle_train_dep_time); $end_train_dep = trim($end_train_dep);
$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 "; $end_train_arrival_date_and_time = $end_now_date ." ".$end_train_arrival; // Train Arrival
$result18 = mysqli_query($con,$sql18) or die(mysqli_error($con)); $end_train_dep_date_and_time = $end_now_date ." ".$end_train_dep; // Train Depature
$row18 = mysqli_fetch_assoc($result18);
$middle_to_next_station_name = $row18['name']; //Station Name $end_next_railway_location_name = "Colombo Fort"; // next location name
?> ?>
<td> <?php echo $middle_train_name ?> </td> <td align="center"> <?php echo $end_train_name ?><br><img class="animate__animated animate__slow animate__slideInRight animate__infinite infinite" src="images/red_arrow.png" style="width:30px;" alt=""> </td>
<td> <?php echo str_replace(' ', '<br>', $middle_train_arrival_date_time) ?> </td> <td> <?php echo str_replace(' ', '<br>', $end_train_arrival_date_and_time) ?> </td>
<td> <?php echo $middle_to_next_station_name ?> </td> <td> <?php echo $end_next_railway_location_name ?> </td>
<td> <?php echo str_replace(' ', '<br>', $middle_train_dep_date_time) ?> </td> <td> <?php echo str_replace(' ', '<br>', $end_train_dep_date_and_time) ?> </td>
<?php <?php
}
$array_call_count++;
}else { }else {
continue; continue;
......
<?php <?php
include "db_connect.php";
if(isset($_POST['logUserid'])){ if(isset($_POST['logUserid'])){
$logUserid = $_POST['logUserid']; $logUserid = $_POST['logUserid'];
...@@ -227,14 +227,25 @@ ...@@ -227,14 +227,25 @@
<h3>Railway Line</h3> <h3>Railway Line</h3>
<div class="x_slider_select" style="width: 100%; margin-top: 0px;"> <div class="x_slider_select" style="width: 100%; margin-top: 0px;">
<select class="myselect form-control"> <select class="myselect form-control">
<option>Select Line</option> <?php
<option>Main Line</option> $sql1 = "SELECT * FROM linelist WHERE logUserid = $logUserid ORDER BY `priority` ASC";
<option>Puththalam Line</option> $result1 = mysqli_query($con,$sql1) or die(mysqli_error($con));
<option>Mathale Line</option> ?>
<option>Nothern Line</option> <option value="select">Select Line</option>
<option>Trincomalee Line</option> <?php
<option>Coast Line</option> while($row1 = mysqli_fetch_array($result1)){
<option>Kelani Valley Line</option>
$slected_line_no = $row1['lineNo'];
$sql2 = "SELECT * FROM railway_line WHERE id = $slected_line_no";
$result2 = mysqli_query($con,$sql2) or die(mysqli_error($con));
$row2 = mysqli_fetch_assoc($result2)
?>
<option value="<?php echo $slected_line_no ?>"><?php echo $row2['line'] ?></option>
<?php
}
?>
</select> </select>
</div> </div>
</div> </div>
...@@ -495,6 +506,11 @@ ...@@ -495,6 +506,11 @@
</div> </div>
</div> </div>
<link
rel="stylesheet"
href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/4.1.1/animate.min.css"
/>
<div class="accordion" id="accordionExample" style="width: 100%; "> <div class="accordion" id="accordionExample" style="width: 100%; ">
<div class="card"> <div class="card">
<div class="card-header" id="headingOne" style="background-color: #4f5dec;"> <div class="card-header" id="headingOne" style="background-color: #4f5dec;">
...@@ -506,105 +522,11 @@ ...@@ -506,105 +522,11 @@
</div> </div>
<div id="collapseOne" class="collapse show" aria-labelledby="headingOne" data-parent="#accordionExample"> <div id="collapseOne" class="collapse show" aria-labelledby="headingOne" data-parent="#accordionExample">
<!-- <div class="card-body"> <!-- Content Add -->
<table class="table table-bordered"> <!-- Content Add -->
<thead class="thead-light"> <!-- Content Add -->
<tr> <!-- Content Add -->
<th>Train</th> <!-- Content Add -->
<th scope="col">Start</th>
<th scope="col">Start Time</th>
<th scope="col">End</th>
<th scope="col"> Arrival </th>
<th scope="col"> Departure </th>
<th scope="col">More</th>
</tr>
</thead>
<tbody>
<tr>
<td> Podi Manike </td>
<td>Colombo Fort</td>
<td>08/25/2021 <br> 05:55</td>
<td>Haputale</td>
<td>08/25/2021 <br> 15:00</td>
<td>08/25/2021 <br> 19:00</td>
<td>
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#exampleModal">
Locations
</button>
<div class="modal fade" id="exampleModal" 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>
<tr>
<td> Adisham Bungalow </td>
<td>Mountain</td>
<td>2 hour</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>
<tr>
<td> Lipton's Seat </td>
<td>Mountain</td>
<td>2 hour</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>
</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>
</tbody>
</table>
</div> -->
</div>
</div>
<div class="card">
<div class="card-header" id="headingTwo">
<h2 class="mb-0">
<button class="btn btn-link btn-block text-left collapsed" type="button" data-toggle="collapse" data-target="#collapseTwo" aria-expanded="false" aria-controls="collapseTwo">
Trip Plan Suggestion 1 - <b>Mathale Line </b>
</button>
</h2>
</div>
<div id="collapseTwo" class="collapse" aria-labelledby="headingTwo" data-parent="#accordionExample">
<div class="card-body">
Some placeholder content for the second accordion panel. This panel is hidden by default.
</div>
</div>
</div>
<div class="card">
<div class="card-header" id="headingThree">
<h2 class="mb-0">
<button class="btn btn-link btn-block text-left collapsed" type="button" data-toggle="collapse" data-target="#collapseThree" aria-expanded="false" aria-controls="collapseThree">
Trip Plan Suggestion 2 - <b>Northern Line </b>
</button>
</h2>
</div>
<div id="collapseThree" class="collapse" aria-labelledby="headingThree" data-parent="#accordionExample">
<div class="card-body">
And lastly, the placeholder content for the third and final accordion panel. This panel is hidden by default.
</div>
</div> </div>
</div> </div>
</div> </div>
......
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