Skip to content
Snippets Groups Projects
Commit 5bb55183 authored by Muhammad Umar Fariz Tumbuan's avatar Muhammad Umar Fariz Tumbuan
Browse files

Merge branch 'master' of http://gitlab.informatika.org/IF3110-2017-K02-OneHundred/TugasBesar1_2017

aaaa how to exit vim??
parents 9b48775d f14fa815
1 merge request!45OneHundred - 13515005 - Husnulzaki Wibisono Haryadi
......@@ -56,6 +56,7 @@ a {
a:link, a:visited {
text-decoration: none;
cursor: pointer;
}
a:hover {
......
......@@ -44,16 +44,41 @@ tr td:nth-child(1),td:nth-child(2) {
}
tr th:nth-child(3) {
}
.edit_operation {
display: block;
}
.edit_button {
border: none;
color: #82d800;
float: left;
margin-left: 15%;
cursor: pointer;
}
.delete_button {
color: #ff0000;
float: right;
margin-right: 15%;
cursor: pointer;
}
.save_button {
border: none;
color: #82d800;
text-decoration: underline;
background-color: transparent;
float: left;
width: 35px;
cursor: pointer;
}
.cancel_button {
color: #ff0000;
float: right;
margin-top: 5%;
margin-right: 15%;
font-size: 0.6em;
width: 25px;
cursor: pointer;
text-decoration: underline;
}
.add_loc_frame {
margin-top: 10%;
......@@ -76,4 +101,5 @@ tr th:nth-child(3) {
}
.add {
width: 50px;
cursor: pointer;
}
......@@ -109,6 +109,7 @@
}
.save {
width: 50px;
cursor: pointer;
}
#profile_link {
background-color: #465d43;
......
<?php
include '../database/dbconnect.php';
$user_id = urldecode($_GET['id']);
$deletedLoc = urldecode($_GET['loc']);
$query = mysqli_query($con,"DELETE FROM driver_prefloc WHERE driver_id='".$user_id."' AND pref_loc='".$deletedLoc."'") or die(mysqli_error($con));
mysqli_close($con);
if ($query) {
header("Location: edit_location.php?id=$user_id");
}
?>
......@@ -6,6 +6,44 @@
<link rel="stylesheet" type="text/css" href="../css/header.css">
</head>
<body>
<script>
function showEdit(editID,saveID,locID,dummylocID,currentlocID,formID,deleteID,cancelID) {
showSave(editID,saveID);
showCancel(deleteID,cancelID);
var temp = document.getElementById(locID).innerHTML;
document.getElementById(locID).style.display = "none";
document.getElementById(dummylocID).value = temp;
document.getElementById(currentlocID).value = temp;
document.getElementById(formID).style.display = "block";
}
function showSave(editID,saveID) {
document.getElementById(editID).style.display = "none";
document.getElementById(saveID).style.display = "block";
}
function showCancel(deleteID,cancelID) {
document.getElementById(deleteID).style.display = "none";
document.getElementById(cancelID).style.display = "block";
}
function copyDummytoNewLoc(dummylocID,newlocID) {
var temp = document.getElementById(dummylocID).value;
document.getElementById(newlocID).value = temp;
}
function hideEdit(editID,saveID,locID,formID,deleteID,cancelID) {
document.getElementById(editID).style.display = "block";
document.getElementById(saveID).style.display = "none";
document.getElementById(locID).style.display = "block";
document.getElementById(formID).style.display = "none";
document.getElementById(deleteID).style.display = "block";
document.getElementById(cancelID).style.display = "none";
}
function validateAddLoc(docID) {
var loc = document.getElementById(docID).value;
if (loc == null || loc == "") {
window.alert("Location can't be blank");
return false;
}
}
</script>
<div class="frame">
<div class="header">
<?php
......@@ -48,28 +86,45 @@
while($row=mysqli_fetch_assoc($query)) {
echo '<tr>
<td>'.$i.'</td>
<td>'.$row['pref_loc'].'</td>
<td><div class="edit_button">✎</div><div class="delete_button"><a href=deletePrefLoc.php?id='.urlencode($user_id).'&loc='.urlencode($row['pref_loc']).'>✖</a></div></td>
<td>
<div id='.'prefloc'.$i.'>'.$row['pref_loc'].'</div>
<div id='.'form_prefloc'.$i.' style="display: none">
<input type="text" style=" height: 100%, width: 100%;" id='.'dummy_prefloc'.$i.' onkeyup="copyDummytoNewLoc(\'dummy_prefloc'.$i.'\',\'new_prefloc'.$i.'\');">
</div>
</td>
<td>
<div class="edit_operation">
<div class="edit_button" id='.'edit_prefloc'.$i.' onClick="showEdit(\'edit_prefloc'.$i.'\',\'save_prefloc'.$i.'\',\'prefloc'.$i.'\',\'dummy_prefloc'.$i.'\',\'current_prefloc'.$i.'\',\'form_prefloc'.$i.'\',\'delete_prefloc'.$i.'\',\'cancel_edit'.$i.'\');">✎</div>
<div id='.'save_prefloc'.$i.' style="display: none">
<form name="edit_prefloc_form" method="POST" action="updateLocation.php" style="display: inline;" onsubmit="return validateAddLoc(\'dummy_prefloc'.$i.'\')">
<input class="save_button" type="submit" value="Save">
<input type="hidden" name="current_prefloc" id='.'current_prefloc'.$i.'>
<input type="hidden" name="new_prefloc" id='.'new_prefloc'.$i.'>
<input type="hidden" name="user_id" value="'.$user_id.'">
</form>
</div>
<div class="delete_button" id='.'delete_prefloc'.$i.'><a href=updateLocation.php?id='.urlencode($user_id).'&loc='.urlencode($row['pref_loc']).'>✖</a></div>
<div class="cancel_button" id='.'cancel_edit'.$i.' style="display: none;" onClick="hideEdit(\'edit_prefloc'.$i.'\',\'save_prefloc'.$i.'\',\'prefloc'.$i.'\',\'form_prefloc'.$i.'\',\'delete_prefloc'.$i.'\',\'cancel_edit'.$i.'\');">Cancel</div>
</div>
</td>
</tr>';
$i++;
}
}
?>
</table>
</div>
<div class="add_loc_frame">
<h2>Add New Location</h2>
<form name="add_location" action="updateLocation.php" method="POST">
<input type="text" name="new_location">
<input type="text" id="hidden_userid" name="hidden_userid" style="display: none;">
<form name="add_location" action="updateLocation.php" method="POST" onsubmit="return validateAddLoc('add_newloc')">
<input type="text" id="add_newloc" name="new_location">
<input type="hidden" name="hidden_userid" value= <?php echo $user_id ?>>
<input type="submit" value="ADD" class="button green add">
</form>
</div>
<a href=<?php echo 'profile.php?id='.$user_id; ?>><div class="button red back">BACK</div></a>
</div>
<?php
echo "<script>document.getElementById('hidden_userid').value =".$user_id."</script>";
?>
</body>
</html>
......@@ -35,7 +35,7 @@
<div class="subheader">
<div class="title"><h1>My Profile</h1></div>
</div>
<form name="edit_identity" method="POST" action="updateProfile.php" enctype="multipart/form-data">
<form name="edit_identity" method="POST" action="updateProfile.php" onsubmit="return validateForm();" enctype="multipart/form-data">
<div class="change_profilepict">
<div class="current_pict_frame">
<img id="current_profile_pict" src="../img/default_profile.jpeg">
......@@ -97,6 +97,18 @@
var arrTemp = inputFile.value.split('\\');
document.getElementById("file_name").value = arrTemp[arrTemp.length - 1];
}
function validateForm() {
if (document.edit_identity.current_name.value == null || document.edit_identity.current_name.value == "") {
window.alert("Name can't be blank");
return false;
} else if (document.edit_identity.current_phone.value == null || document.edit_identity.current_phone.value == "") {
window.alert("Phone can't be blank");
return false;
} else if (document.edit_identity.current_phone.value.length < 9 || document.edit_identity.current_phone.value.length > 12) {
window.alert("Phone number should be 9 to 12 characters long");
return false;
}
}
</script>
</body>
</html>
......@@ -9,6 +9,25 @@
if ($query) {
header("Location: edit_location.php?id=$user_id");
}
} else if (!empty($_POST['new_prefloc'])) {
$user_id = $_POST['user_id'];
$current_prefloc = $_POST['current_prefloc'];
$new_prefloc = $_POST['new_prefloc'];
include '../database/dbconnect.php';
$query = mysqli_query($con,"UPDATE driver_prefloc SET pref_loc = '$new_prefloc' WHERE driver_id = '$user_id' AND pref_loc = '$current_prefloc'") or die(mysqli_error($con));
mysqli_close($con);
if ($query) {
header("Location: edit_location.php?id=$user_id");
}
}
} else if ($_SERVER["REQUEST_METHOD"] == "GET") {
include '../database/dbconnect.php';
$user_id = urldecode($_GET['id']);
$deletedLoc = urldecode($_GET['loc']);
$query = mysqli_query($con,"DELETE FROM driver_prefloc WHERE driver_id='".$user_id."' AND pref_loc='".$deletedLoc."'") or die(mysqli_error($con));
mysqli_close($con);
if ($query) {
header("Location: edit_location.php?id=$user_id");
}
}
?>
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