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

Merge branch 'IT18500790' into 'master'

Trip plan custermized

See merge request !10
parents e81406de ba159270
<?php
session_start();
include "db_connect.php";
$logUserid = mysqli_real_escape_string($con,$_POST['logUserid']);
$catDropValue = mysqli_real_escape_string($con,$_POST['catDropValue']);
$sql1 = "SELECT * FROM catlist WHERE logUserid = $logUserid ORDER BY `priority` ASC ";
$result1 = mysqli_query($con,$sql1) or die(mysqli_error($con));
$cat_list = array();
while($row1 = mysqli_fetch_array($result1)){
array_push($cat_list, $row1['catNo']);
}
function repositionArrayElement(array &$array, $key, int $order): void
{
if(($a = array_search($key, array_keys($array))) === false){
throw new \Exception("The {$key} cannot be found in the given array.");
}
$p1 = array_splice($array, $a, 1);
$p2 = array_splice($array, 0, $order);
$array = array_merge($p2, $p1, $array);
}
$cat_index_in_array = array_search($catDropValue,$cat_list);
repositionArrayElement($cat_list, $cat_index_in_array, 0);
$sql3 = "SELECT * FROM catlist WHERE logUserid = '$logUserid'";
$result3 = mysqli_query($con,$sql3) or die(mysqli_error($con));
$rowcount3 = mysqli_num_rows($result3);
if($rowcount3 > 0){
$sql4 = "DELETE FROM catlist WHERE logUserid='$logUserid'";
$result4 = mysqli_query($con,$sql4) or die(mysqli_error($con));
}
for($i = 0; $i < 6; $i++){
$priority = $i + 1;
$catNo = $cat_list[$i];
$sql1 = "INSERT INTO `catlist`(`logUserid`, `catNo`, `priority`) VALUES ('$logUserid','$catNo','$priority')";
$result1 = mysqli_query($con,$sql1) or die(mysqli_error($con));
}
?>
\ No newline at end of file
<?php
session_start();
include "db_connect.php";
$logUserid = mysqli_real_escape_string($con,$_POST['logUserid']);
$lineDropValue = mysqli_real_escape_string($con,$_POST['lineDropValue']);
$sql1 = "SELECT * FROM linelist WHERE logUserid = $logUserid ORDER BY `priority` ASC ";
$result1 = mysqli_query($con,$sql1) or die(mysqli_error($con));
$line_list = array();
while($row1 = mysqli_fetch_array($result1)){
array_push($line_list, $row1['lineNo']);
}
function repositionArrayElement(array &$array, $key, int $order): void
{
if(($a = array_search($key, array_keys($array))) === false){
throw new \Exception("The {$key} cannot be found in the given array.");
}
$p1 = array_splice($array, $a, 1);
$p2 = array_splice($array, 0, $order);
$array = array_merge($p2, $p1, $array);
}
$line_index_in_array = array_search($lineDropValue,$line_list);
repositionArrayElement($line_list, $line_index_in_array, 0);
$sql3 = "SELECT * FROM linelist WHERE logUserid = '$logUserid'";
$result3 = mysqli_query($con,$sql3) or die(mysqli_error($con));
$rowcount3 = mysqli_num_rows($result3);
if($rowcount3 > 0){
$sql4 = "DELETE FROM linelist WHERE logUserid='$logUserid'";
$result4 = mysqli_query($con,$sql4) or die(mysqli_error($con));
}
for($i = 0; $i < 6; $i++){
$priority = $i + 1;
$lineNo = $line_list[$i];
$sql1 = "INSERT INTO `linelist`(`logUserid`, `lineNo`, `priority`) VALUES ('$logUserid','$lineNo','$priority')";
$result1 = mysqli_query($con,$sql1) or die(mysqli_error($con));
}
?>
\ No newline at end of file
...@@ -124,7 +124,7 @@ ...@@ -124,7 +124,7 @@
if (req.readyState == 4) { if (req.readyState == 4) {
if (req.status == 200) { if (req.status == 200) {
// alert(req.responseText); // alert(req.responseText);
console.log(req.responseText); // console.log(req.responseText);
document.getElementById(`collapseOne`).innerHTML = req.responseText; document.getElementById(`collapseOne`).innerHTML = req.responseText;
} }
} }
...@@ -226,13 +226,10 @@ ...@@ -226,13 +226,10 @@
<div class="x_slider_form_input_wrapper float_left"> <div class="x_slider_form_input_wrapper float_left">
<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" onchange="setToLine(this.value);">
<?php <?php
$sql1 = "SELECT * FROM linelist WHERE logUserid = $logUserid ORDER BY `priority` ASC"; $sql1 = "SELECT * FROM linelist WHERE logUserid = $logUserid ORDER BY `priority` ASC";
$result1 = mysqli_query($con,$sql1) or die(mysqli_error($con)); $result1 = mysqli_query($con,$sql1) or die(mysqli_error($con));
?>
<option value="select">Select Line</option>
<?php
while($row1 = mysqli_fetch_array($result1)){ while($row1 = mysqli_fetch_array($result1)){
$slected_line_no = $row1['lineNo']; $slected_line_no = $row1['lineNo'];
...@@ -242,7 +239,7 @@ ...@@ -242,7 +239,7 @@
$row2 = mysqli_fetch_assoc($result2) $row2 = mysqli_fetch_assoc($result2)
?> ?>
<option value="<?php echo $slected_line_no ?>"><?php echo $row2['line'] ?></option> <option value="<?php echo $row2['id'] ?>"><?php echo $row2['line'] ?></option>
<?php <?php
} }
?> ?>
...@@ -252,28 +249,30 @@ ...@@ -252,28 +249,30 @@
</div> </div>
<div class="col-md-12"> <div class="col-md-12">
<div class="x_slider_form_input_wrapper float_left"> <div class="x_slider_form_input_wrapper float_left">
<h3>Start Location</h3> <h3>Location Category</h3>
<div class="x_slider_select" style="width: 100%; margin-top: 0px;">
<select class="myselect form-control">
<option>Select Location</option>
<option>Colombo</option>
<option>Maradhana</option>
<option>Kurunagala</option>
</select>
</div>
</div>
</div>
<div class="col-md-12">
<div class="form-sec-header">
<h3>End Location</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" onchange="setToCat(this.value)">
<option>Select Location</option> <?php
<option>Pattipola</option> $sql3 = "SELECT * FROM catlist WHERE logUserid = $logUserid ORDER BY `priority` ASC";
<option>Ella</option> $result3 = mysqli_query($con,$sql3) or die(mysqli_error($con));
<option>Badulla</option> while($row3 = mysqli_fetch_array($result3)){
</select>
</div> $selected_cat_id = $row3['catNo'];
$sql4 = "SELECT * FROM category WHERE id = '$selected_cat_id' ";
$result4 = mysqli_query($con,$sql4) or die(mysqli_error($con));
$row4 = mysqli_fetch_assoc($result4)
?>
<option value="<?php echo $row4['id'] ?>"><?php echo $row4['name'] ?></option>
<?php
}
?>
</select>
</div>
</div> </div>
</div> </div>
<div class="col-md-12"> <div class="col-md-12">
...@@ -298,6 +297,57 @@ ...@@ -298,6 +297,57 @@
</div> </div>
</div> </div>
</div> </div>
<script>
function setToCat(value) {
let logUserid = document.getElementById(`logUserid`).value;
let catDropValue = value;
var formData = new FormData();
formData.append('logUserid', logUserid);
formData.append('catDropValue', catDropValue);
var req = getXmlHttpRequestObject();
if (req) {
req.onreadystatechange = function() {
if (req.readyState == 4) {
if (req.status == 200) {
// alert(req.responseText);
// console.log(req.responseText);
createTripPlan();
}
}
}
req.open("POST", 'sub_arrange_cat.php', true);
req.send(formData);
}
}
function setToLine(value){
let logUserid = document.getElementById(`logUserid`).value;
let lineDropValue = value;
var formData = new FormData();
formData.append('logUserid', logUserid);
formData.append('lineDropValue', lineDropValue);
var req = getXmlHttpRequestObject();
if (req) {
req.onreadystatechange = function() {
if (req.readyState == 4) {
if (req.status == 200) {
createTripPlan();
}
}
}
req.open("POST", 'sub_arrange_line.php', true);
req.send(formData);
}
}
</script>
<div class="col-xl-9 col-lg-8 col-md-12 col-sm-12 col-12"> <div class="col-xl-9 col-lg-8 col-md-12 col-sm-12 col-12">
<div class="x_carbooking_right_section_wrapper float_left"> <div class="x_carbooking_right_section_wrapper float_left">
<div class="row"> <div class="row">
......
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