diff --git a/src/hide.php b/src/hide.php new file mode 100644 index 0000000000000000000000000000000000000000..31343f0480eea64196cd683c76f7326ab8af93dc --- /dev/null +++ b/src/hide.php @@ -0,0 +1,27 @@ +<?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 diff --git a/src/history.php b/src/history.php index 28c8f479c15d5f66949fc93445fd1dd21965409e..17530a51aed2b0ce2b03b2e54183157dac0bb3cb 100644 --- a/src/history.php +++ b/src/history.php @@ -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='☆'; - break; - case 2: - $rating='☆☆'; - break; - case 3: - $rating='☆☆☆'; - break; - case 4: - $rating='☆☆☆☆'; - break; - case 4: - $rating='☆☆☆☆☆'; - 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.' → '.$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='☆'; + break; + case 2: + $rating='☆☆'; + break; + case 3: + $rating='☆☆☆'; + break; + case 4: + $rating='☆☆☆☆'; + break; + case 4: + $rating='☆☆☆☆☆'; + 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.' → '.$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.' → '.$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.' → '.$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> diff --git a/src/js/fan.js b/src/js/fan.js index a627e92a87e2fe92a26caa5e1c06ea6dc1beedc0..61e185cebcb431b0d6f04a4f8ae1c9b0ef625321 100644 --- a/src/js/fan.js +++ b/src/js/fan.js @@ -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