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

Merge branch 'IT18500790' into 'master'

Create trip plan

See merge request !6
parents 21b8f4b9 bc440486
......@@ -4,6 +4,7 @@
include "db_connect.php";
$logUserid = mysqli_real_escape_string($con,$_POST['logUserid']);
$round = 'first';
$sql1 = "SELECT * FROM user_details WHERE logUserid = '$logUserid' ";
$result1 = mysqli_query($con,$sql1) or die(mysqli_error($con));
......@@ -193,7 +194,6 @@
$end_date = $ini_end_date;
$start_time = '05:00:00';
$start_date_time = $ini_start_date ." ". $start_time;
$main_start_time = "";
?>
......@@ -257,8 +257,8 @@
$colombo_train_name = $row16['trainname']; //Train name
$colombo_name = "Colombo Fort"; // Start name;
$colombo_train_arrival_date_time = $start_date ." ".$colombo_train_arrival_time; // Arrival
$colombo_train_dep_date_time = $start_date ." ".$colombo_train_dep_time; //Departure
$main_start_time = $colombo_train_dep_date_time;
$colombo_train_dep_date_time = $start_date ." ".trim($colombo_train_dep_time); //Departure
$start_date_time = $colombo_train_dep_date_time;
$colombo_to_next_station = $row17['colombo_to_next'];
......@@ -286,7 +286,131 @@
// echo $start_date_time ."<br>";
// $start_date_time = date('Y-m-d H:i:s', strtotime($start_date_time.'+12 hour'));
echo $main_start_time ."<br>";
// echo $main_start_time ."<br>";
$sql13 = "SELECT * FROM final_railway_station WHERE `line` = $now_line_no AND `train_no` = $c ";
$result13 = mysqli_query($con,$sql13) or die(mysqli_error($con));
$row13 = mysqli_fetch_assoc($result13);
$location_station_name = $row13['name'];
?>
<tr>
<td> <?php echo $location_station_name ?> </td>
<td> <button type="button" class="btn btn-primary" data-toggle="modal" data-target="#first<?php echo $c ?>"> Locations </button>
<div class="modal fade" id="first<?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
$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));
$full_time_to_visit = 0;
while($row19 = mysqli_fetch_array($result19)){
$station_near_by_place_id = $row19['placeId'];
$station_near_by_cat_id = $row19['placeCatId'];
$station_near_by_es_time = $row19['placeEsTime'];
$full_time_to_visit = $full_time_to_visit + $station_near_by_es_time;
$sql20 = "SELECT * FROM places WHERE id = $station_near_by_place_id ";
$result20 = mysqli_query($con,$sql20) or die(mysqli_error($con));
$row20 = mysqli_fetch_assoc($result20);
$station_near_by_place_name = $row20['place_name'];
$sql21 = "SELECT * FROM category WHERE id = $station_near_by_cat_id ";
$result21 = mysqli_query($con,$sql21) or die(mysqli_error($con));
$row21 = mysqli_fetch_assoc($result21);
$station_near_by_cat_name = $row21['name'];
?>
<tr>
<td> <?php echo $station_near_by_place_name ?> </td>
<td> <?php echo $station_near_by_cat_name ?> </td>
<td> <?php echo $station_near_by_es_time . " 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
}
?>
</tbody>
</table>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-danger" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
</td>
<?php
$full_time_to_visit_hour = "+".$full_time_to_visit." hour";
$start_date_time = date('Y-m-d H:i:s', strtotime($start_date_time. $full_time_to_visit_hour));
$separate_date_time = explode(" ", $start_date_time);
$separate_date = $separate_date_time[0];
$separate_time = $separate_date_time[1];
$max_time = '18:00:00';
$separate_time_str = strtotime($separate_time);
$max_time_str = strtotime($max_time);
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";
$result22 = mysqli_query($con,$sql22) or die(mysqli_error($con));
$specific_station_train_no = array();
while($row22 = mysqli_fetch_array($result22)){
$specific_start_time = $row22['arrival'];
$specific_train_id = $row22['id'];
$str_sec_start_time = strtotime($separate_time);
$str_sec_specific_start_time = strtotime($specific_start_time);
if($str_sec_start_time < $str_sec_specific_start_time) {
array_push($specific_station_train_no,$specific_train_id);
}
}
$specific_station_train_no_count = count($specific_station_train_no);
if($specific_station_train_no_count > 0) {
$specific_train_id = $specific_station_train_no[0];
}
}else {
continue;
......
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