Skip to content
Snippets Groups Projects
Commit 863988da authored by Nur Latifah Ulfah's avatar Nur Latifah Ulfah
Browse files

fix hide

parent 979ec9c3
No related merge requests found
<?php
require_once 'dbconfig.php';
$sqlconn = mysqli_connect(DB_SERVER, DB_USERNAME, DB_PASSWORD, DB_NAME);
if (!$sqlconn) {
die('mySQL connection failed');
}
$type = $_GET["type"];
$id = $_GET["id"];
if ($type == 0) {
$ishide=1;
$sqlquery = "UPDATE orderhistory SET ishide_cust=? WHERE order_id=?";
$stmt = mysqli_prepare($sqlconn, $sqlquery);
mysqli_stmt_bind_param($stmt, "ii", $ishide, $id);
mysqli_stmt_execute($stmt);
}else{
$ishide=1;
$sqlquery = "UPDATE orderhistory SET ishide_driver=? WHERE order_id=?";
$stmt = mysqli_prepare($sqlconn, $sqlquery);
mysqli_stmt_bind_param($stmt, "ii", $ishide, $id);
mysqli_stmt_execute($stmt);
}
?>
\ No newline at end of file
......@@ -24,7 +24,7 @@
}
//AMBIL DATA HISTORY ORDER
$query_order_history = 'SELECT order_id, date, u_driver, source, destination, rating_given, comment_given, img_name FROM orderhistory INNER JOIN userinfo ON orderhistory.u_customer=userinfo.username AND userinfo.username=?';
$query_order_history = 'SELECT order_id, date, u_customer, u_driver, source, destination, rating_given, comment_given, img_name, ishide_cust FROM orderhistory INNER JOIN userinfo ON orderhistory.u_customer=userinfo.username AND userinfo.username=?';
$order_history = mysqli_prepare($sqlconn, $query_order_history);
// Bind variables
......@@ -34,11 +34,11 @@
// Simpan Hasil query
mysqli_stmt_store_result($order_history);
// username exist
mysqli_stmt_bind_result($order_history, $id, $date, $u_driver, $source, $destination, $rating_given, $comment_given, $img_name);
mysqli_stmt_bind_result($order_history, $id, $date, $u_customer, $u_driver, $source, $destination, $rating_given, $comment_given, $img_name, $ishide_cust);
}
//AMBIL DATA DRIVER HISTORY
$query_driver_history = 'SELECT order_id, date, u_customer, source, destination, rating_given, comment_given FROM orderhistory INNER JOIN userinfo ON orderhistory.u_driver=userinfo.username AND userinfo.username=?';
$query_driver_history = 'SELECT order_id, date, u_customer, u_driver, source, destination, rating_given, comment_given, img_name, ishide_driver FROM orderhistory INNER JOIN userinfo ON orderhistory.u_customer=userinfo.username AND orderhistory.u_driver=?';
$driver_history = mysqli_prepare($sqlconn, $query_driver_history);
// Bind variables
......@@ -48,7 +48,7 @@
// Simpan Hasil query
mysqli_stmt_store_result($driver_history);
// username exist
mysqli_stmt_bind_result($driver_history, $id, $date, $u_customer, $source, $destination, $rating_given, $comment_given);
mysqli_stmt_bind_result($driver_history, $id, $date, $u_customer, $u_driver, $source, $destination, $rating_given, $comment_given, $img_name, $ishide_driver);
}
?>
<html>
......@@ -100,48 +100,51 @@
<div id="order" class="tabcontent active">
<?php
while (mysqli_stmt_fetch($order_history)) {
switch ($rating_given) {
case 1:
$rating='&#9734;';
break;
case 2:
$rating='&#9734;&#9734;';
break;
case 3:
$rating='&#9734;&#9734;&#9734;';
break;
case 4:
$rating='&#9734;&#9734;&#9734;&#9734;';
break;
case 4:
$rating='&#9734;&#9734;&#9734;&#9734;&#9734;';
break;
default:
$rating='';
}
$date=strtotime($date);
$id_hide="'order$id'";
$listhistory = '
<!-- Start List Item -->
<div class="row mt40" id="order'.$id.'">
<div class="col-4 photo-container px15">
<img src="img/'.$img_name.'" class="border">
</div>
<div class="col-8 relative">
<div class="date">'.date("l, F j",$date).'th '.date("Y",$date).'</div>
<div class="driver-name">'.$u_driver.'</div>
<div class="destination mt10">'.$source.' &#8594; '.$destination.'</div>
<div class="rating mt10">You rated: <span class="orange">'.$rating.'</span></div>
<div class="comment">You commented:
<p class="m0">'.$comment_given.'</p></div>
<div class="hide-btn r0 t0">
<button class="uppercase btn red-bg" onclick="hide('.$id_hide.')">Hide</button>
if ($ishide_cust == 0){
switch ($rating_given) {
case 1:
$rating='&#9734;';
break;
case 2:
$rating='&#9734;&#9734;';
break;
case 3:
$rating='&#9734;&#9734;&#9734;';
break;
case 4:
$rating='&#9734;&#9734;&#9734;&#9734;';
break;
case 4:
$rating='&#9734;&#9734;&#9734;&#9734;&#9734;';
break;
default:
$rating='';
}
$date=strtotime($date);
$id_hide="'order$id'";
$listhistory = '
<!-- Start List Item -->
<div class="row mt40" id="order'.$id.'">
<div class="col-4 photo-container px15">
<img src="img/'.$img_name.'" class="border">
</div>
<div class="col-8 relative">
<div class="date">'.date("l, F j",$date).'th '.date("Y",$date).'</div>
<div class="driver-name">'.$u_driver.'</div>
<div class="destination mt10">'.$source.' &#8594; '.$destination.'</div>
<div class="rating mt10">You rated: <span class="orange">'.$rating.'</span></div>
<div class="comment">You commented:
<p class="m0">'.$comment_given.'</p></div>
<div class="hide-btn r0 t0">
<button class="uppercase btn red-bg" onclick="hideCust('.$id_hide.','.$id.')">Hide</button>
</div>
</div>
</div>
</div>
<!-- End List Item -->';
echo $listhistory;
}
<!-- End List Item -->';
echo $listhistory;
}
?>
</div>
......@@ -152,28 +155,30 @@
<?php
while (mysqli_stmt_fetch($driver_history)) {
$date=strtotime($date);
$id_hide="'driver$id'";
$listhistory = '
<!-- Start List Item -->
<div class="row mt40" id="driver'.$id.'">
<div class="col-4 photo-container px15">
<img src="img/'.$img_name.'" class="border">
</div>
<div class="col-8 relative">
<div class="date">'.date("l, F j",$date).'th '.date("Y",$date).'</div>
<div class="driver-name">'.$u_customer.'</div>
<div class="destination mt5">'.$source.' &#8594; '.$destination.'</div>
<div class="rating mt5">gave <span class="orange">'.$rating_given.'</span> stars for this order</div>
<div class="comment mt5">and left comment:
<p class="m0">'.$comment_given.'</p></div>
<div class="hide-btn r0 t0">
<button class="uppercase btn red-bg" onclick="hide('.$id_hide.')">Hide</button>
if ($ishide_driver == 0){
$id_hide="'driver$id'";
$listhistory = '
<!-- Start List Item -->
<div class="row mt40" id="driver'.$id.'">
<div class="col-4 photo-container px15">
<img src="img/'.$img_name.'" class="border">
</div>
<div class="col-8 relative">
<div class="date">'.date("l, F j",$date).'th '.date("Y",$date).'</div>
<div class="driver-name">'.$u_customer.'</div>
<div class="destination mt5">'.$source.' &#8594; '.$destination.'</div>
<div class="rating mt5">gave <span class="orange">'.$rating_given.'</span> stars for this order</div>
<div class="comment mt5">and left comment:
<p class="m0">'.$comment_given.'</p></div>
<div class="hide-btn r0 t0">
<button class="uppercase btn red-bg" onclick="hideDriver('.$id_hide.','.$id.')">Hide</button>
</div>
</div>
</div>
</div>
<!-- End List Item -->';
<!-- End List Item -->';
echo $listhistory;
echo $listhistory;
}
}
?>
</div>
......
......@@ -22,33 +22,50 @@ function openTab(evt, tabName) {
evt.currentTarget.className += " active";
}
function hide(id) {
document.getElementById(id).style.display = "none";
function hideCust(idhide, id){
var xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
document.getElementById(idhide).style.display = "none";
}
};
xmlhttp.open("GET", "hide.php?type=0&id="+id, true);
xmlhttp.send();
}
function hideDriver(idhide, id){
var xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
document.getElementById(idhide).style.display = "none";
}
};
xmlhttp.open("GET", "hide.php?type=1&id="+id, true);
xmlhttp.send();
}
//INPUT FILE
'use strict';
;( function ( document, window, index )
{
var inputs = document.querySelectorAll( '.inputfile' );
Array.prototype.forEach.call( inputs, function( input )
{
var label = input.nextElementSibling,
labelVal = label.innerHTML;
input.addEventListener( 'change', function( e )
{
if( fileName )
label.querySelector( 'span' ).innerHTML = fileName;
else
label.innerHTML = labelVal;
});
// Firefox bug fix
input.addEventListener( 'focus', function(){ input.classList.add( 'has-focus' ); });
input.addEventListener( 'blur', function(){ input.classList.remove( 'has-focus' ); });
});
}( document, window, 0 ));
\ No newline at end of file
// 'use strict';
// ;( function ( document, window, index )
// {
// var inputs = document.querySelectorAll( '.inputfile' );
// Array.prototype.forEach.call( inputs, function( input )
// {
// var label = input.nextElementSibling,
// labelVal = label.innerHTML;
// input.addEventListener( 'change', function( e )
// {
// if( fileName )
// label.querySelector( 'span' ).innerHTML = fileName;
// else
// label.innerHTML = labelVal;
// });
// // Firefox bug fix
// input.addEventListener( 'focus', function(){ input.classList.add( 'has-focus' ); });
// input.addEventListener( 'blur', function(){ input.classList.remove( 'has-focus' ); });
// });
// }( document, window, 0 ));
\ No newline at end of file
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