Skip to content
Snippets Groups Projects
Commit db86a0d7 authored by Mikhael Artur Darmakesuma's avatar Mikhael Artur Darmakesuma
Browse files

Login feature added

parents 530ced36 08cd9e07
1 merge request!42Projekers - 13515051 - Girvandi Ilyas
......@@ -3,11 +3,17 @@
include "../model/user.php";
include "../model/order.php";
if(isset($_GET['drivername']) && isset($_GET['id'])){
if(isset($_GET['drivername']) && isset($_GET['id']) && isset($_GET['pickup']) && isset($_GET['destination'])){
$userId = $_GET['id'];
$driverName = $_GET['drivername'];
$pickup = $_GET['pickup'];
$destination = $_GET['destination'];
$user = new User();
$result = $user->getDriverNotId($userId);
$result = $user->getDriverNotId($userId, $pickup, $destination);
header('Content-Type: text/html');
$txt = '<div class="driver-box"><h1>PREFERRED DRIVERS</h1>';
//Process to find the driver
......@@ -31,7 +37,7 @@ if(isset($_GET['drivername']) && isset($_GET['id'])){
$txt = $txt . '</div>';
$txt = $txt . '<div class="driver-box"><h1>OTHER DRIVERS</h1>';
//Process other drivers
$result = $user->getDriverNotId($userId);
$result = $user->getDriverNotId($userId, $pickup, $destination);
while($row = mysqli_fetch_array($result)){
if($row['name'] !== $driverName){
//get drier rating
......
......@@ -23,12 +23,14 @@ function getDriver() {
var xmlhttp = new XMLHttpRequest();
//Check if user inserted preferred driver's name
var drivername = (document.getElementById('preferred-driver').value) ? document.getElementById('preferred-driver').value : null;
var pickup = document.getElementById('pickup').value;
var destination = document.getElementById('destination').value;
xmlhttp.onreadystatechange = function () {
if(xmlhttp.readyState == 4 && xmlhttp.status == 200){
document.getElementsByClassName('second-page')[0].innerHTML = this.responseText;
}
};
xmlhttp.open('GET','../controller/orderController.php?drivername='+drivername+'&id='+sessionid,true);
xmlhttp.open('GET','../controller/orderController.php?drivername='+drivername+'&id='+sessionid+'&pickup='+pickup+'&destination='+destination,true);
xmlhttp.send();
}
function chooseDriver(id){
......
......@@ -84,10 +84,13 @@ class User {
mysqli_close($con);
return $result;
}
function getDriverNotId($id){
function getDriverNotId($id, $pickup, $destination){
//Driver is limited to the pickup and destination
$con = mysqli_connect('localhost','root','','projekers');
mysqli_select_db($con,'projekers');
$query = "SELECT id,name,image FROM user WHERE isDriver=1 AND not id=" . $id;
//select * from user natural join pref_loc where (location like 'bec%' or location like '%kopo%') and isDriver=1 and not id=1
$query = "SELECT DISTINCT id,name,image FROM user NATURAL JOIN pref_loc WHERE (location LIKE '%".
$pickup."%' OR location LIKE '%".$destination."%') AND isDriver=1 AND not id=" . $id;
$result = mysqli_query($con,$query);
mysqli_close($con);
return $result;
......@@ -116,4 +119,6 @@ class User {
mysqli_close($con);
return $result;
}
//function getD
// select * from user natural join pref_loc where (location like 'bec%' or location like '%kopo%') and isDriver=1 and not id=1
}
\ No newline at end of file
......@@ -10,10 +10,10 @@
<form action="../controller/orderController.php" method="post">
<div class="first-page">
<div class="input-box">
<label>Picking Point</label><input type="text" name="pickup" placeholder="Pickup Point"/>
<label>Picking Point</label><input type="text" name="pickup" id="pickup" placeholder="Pickup Point"/>
</div>
<div class="input-box">
<label>Destination</label><input type="text" name="destination" placeholder="Destination Point"/>
<label>Destination</label><input type="text" name="destination" id="destination" placeholder="Destination Point"/>
</div>
<div class="input-box">
<label>Preferred Driver</label><input type="text" name="preferred-driver" id="preferred-driver" placeholder="(optional)" value=""/>
......
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