Skip to content
Snippets Groups Projects
Commit eb1de96f authored by Aldrich Valentino Halim's avatar Aldrich Valentino Halim
Browse files
parents 1c9ea2a4 71004957
1 merge request!42Projekers - 13515051 - Girvandi Ilyas
File moved
<?php
/* Model */
include "../model/user.php";
//TODO: tambahin redirect klo get kosong
$user = new User;
$user_id = $_GET['id'];
$result = $user->getUserById($user_id);
header('Content-Type: text/xml');
$xml = '<user>';
while($row = mysqli_fetch_array($result)){
$xml = $xml . '<name>' . $row['name'] . '</name><username>' . $row['username'] .
'</username><email>' . $row['email'] . '</email><image>' . $row['image'] .
'</image><phone>' . $row['phone'] . '</phone><driver>' . $row['isDriver'] . '</driver>';
}
$xml = $xml . '</user>';
print $xml;
\ No newline at end of file
......@@ -81,10 +81,29 @@ button{
.submit{
width: 100%;
height: 40px;
background-color: #82D800;
border-color: #000000;
border-radius: 5px;
font-size: 130%;
font: 130% Serif;
padding: 0 0 0 0;
color: #000000;
border-width: 1px;
}
.backbutton{
width: 15%;
}
.back{
float: left;
background-color: #d50027;
color: black;
border-color: black;
border-radius: 5px;
padding: 5px 12px;
text-decoration: none;
border-width: 1px;
border-style: outset;
font: 130% Serif;
}
......@@ -85,6 +85,6 @@
.link{
text-align: left;
font-family: "Arial";
width: 69%;
width: 68%;
text-align: left;
}
\ No newline at end of file
function hideMe(i){
var textHidden = false;
textHidden = !textHidden;
function editsave(i){
var submitForm = document.getElementById("locationform"+i);
var textBox = document.getElementById("locationtext"+i);
var inputBox = document.getElementById("locationinput"+i);
var image = document.getElementById("imageeditsave"+i);
......@@ -11,11 +10,24 @@ function hideMe(i){
inputBox.setAttribute("style","display:block");
inputBox.value = textBox.innerHTML;
image.src = "../img/floppy.png";
}
else{
} else {
var form = document.forms["locationform"+i];
textBox.setAttribute("style","display:block");
inputBox.type = "hidden";
inputBox.setAttribute("style","display:none");
textBox.innerHTML = inputBox.value;
image.src = "../img/pencil.png";
form.action = "editsave-location.php";
form.submit();
}
}
function del(i){
var textBox = document.getElementById("locationtext"+i);
var form = document.forms["locationform"+i];
var check = confirm ("Delete "+textBox.innerHTML+" from preferred location?");
if (check === true){
form.action = "delete-location.php";
form.submit();
}
}
\ No newline at end of file
......@@ -119,6 +119,30 @@ class User {
mysqli_close($con);
return $result;
}
function addLocation($id, $location) {
$con = mysqli_connect('localhost','root','','projekers');
mysqli_select_db($con, 'projekers');
$sql = "INSERT INTO pref_loc (" . $id . ", '" . (string)$location . "')";
mysqli_query($con,$sql);
mysqli_close($con);
}
function updateLocation($id, $location1, $location2) {
$con = mysqli_connect('localhost','root','','projekers');
mysqli_select_db($con, 'projekers');
$sql = "UPDATE pref_loc set location='" . (string)$location2 . "' where id=" . $id . " AND location='" . (string)$location1 . "'";
mysqli_query($con,$sql);
mysqli_close($con);
}
function deleteLocation($id, $location) {
$con = mysqli_connect('localhost','root','','projekers');
mysqli_select_db($con, 'projekers');
$sql = "DELETE FROM pref_loc where id=" . $id . " AND location='" . (string)$location . "'";
mysqli_query($con,$sql);
mysqli_close($con);
}
//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
<html>
<head>
<title>Projekers - Edit Prefered Location</title>
<title>Projekers - Edit Preferred Location</title>
<link rel = "stylesheet" href = "../css/edit-prefered-location.css">
<link rel = "stylesheet" href = "../css/primary.css">
<script src = "../js/edit-prefered-location.js"></script>
......@@ -11,7 +11,7 @@
<?php
include "../model/user.php";
$user = new User;
$user_id = 1;
$user_id = $_GET['id'];
$result = $user->getPreferredLocation($user_id);
if ($result->num_rows > 0) {
echo '
......@@ -26,25 +26,29 @@
while($row = $result->fetch_assoc()) {
echo '
<tr>
<td class="tabno">'.$i.'</td>
<td class="tabloc">
<div id="locationtext'.$i.'">'.$row["location"].'</div>
<input class="locationinput" id="locationinput'.$i.'" type="hidden">
</td>
<td class="tabact">
<div class="addset" align="center">
<div class="editsavebox">
<button onClick=hideMe('.$i.') class="editsave">
<img src="../img/pencil.png" class="editsavebutton" id="imageeditsave'.$i.'">
</button>
<form name="locationform'.$i.'" method="post">
<td class="tabno">'.$i.'</td>
<td class="tabloc">
<input class="locationinput" id="id'.$i.'" type="hidden">
<div id="locationtext'.$i.'">'.$row["location"].'</div>
<input class="locationinput" id="locationinput'.$i.'" type="hidden">
<input class="oldlocation" id="oldlocation'.$i.'" type="hidden" value="'.$row["location"].'">
</td>
<td class="tabact">
<div class="addset" align="center">
<div class="editsavebox">
<button type="button" onClick=editsave('.$i.') class="editsave">
<img src="../img/pencil.png" class="editsavebutton" id="imageeditsave'.$i.'">
</button>
</div>
<div>
<button onClick=del('.$i.') class="delete">
<img src="../img/delete.png" class="deletebutton" id="imagedelete'.$i.'">
</button>
</div>
</div>
<div>
<button onClick=f() class="delete">
<img src="../img/delete.png" class="deletebutton" id="imagedelete'.$i.'">
</button>
</div>
</div>
</td>
</td>
</form>
</tr>';
$i++;
}
......@@ -52,20 +56,26 @@
</table>
';
} else {
echo "No prefered location, add one using the box below.";
echo "No preferred location, add one using the box below.";
}
?>
<br>
<br>
<h2>ADD NEW LOCATION:</h2>
<div class="addset">
<div class="field"><input type="text"></div>
<div class="submitbutton">
<input type="Submit" value="ADD" class="submit">
</div>
<form name="addlocationform" method="post" action="add-location.php">
<div class="field"><input type="text"></div>
<div class="submitbutton">
<input type="Submit" value="ADD" class="submit">
</div>
</form>
</div>
<br>
<br>
<div>
<div class="backbutton">
<a class="back" href="dashboard.php?id=<?php echo $_GET['id'];?>">BACK</a>
</div>
</div>
</div>
</body>
......
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