diff --git a/admin/controllers/feedback/add.php b/admin/controllers/feedback/add.php index eed0e6e..c75a19e 100644 --- a/admin/controllers/feedback/add.php +++ b/admin/controllers/feedback/add.php @@ -5,6 +5,9 @@ if (!empty($_POST)) { addFeedbackOrder(); + echo "
Done! Thư phản hồi của bạn đã được gửi đến hệ thống của quán Chị Kòi. Cảm ơn bạn đã gửi lại phản hồi về quán.

Hãy đến Dashboard
"; + require('content/views/feedback/result.php'); + exit; } if (isset($_GET['order_id'])) { diff --git a/admin/models/feedbacks.php b/admin/models/feedbacks.php index c6cfa24..e760c2f 100644 --- a/admin/models/feedbacks.php +++ b/admin/models/feedbacks.php @@ -3,7 +3,10 @@ use PHPMailer\PHPMailer\Exception; use PHPMailer\PHPMailer\PHPMailer; -function addFeedbackOrder() +/** + * @return void + */ +function addFeedbackOrder(): void { $feedback_add = [ 'id' => intval($_POST['feedback_id']), @@ -18,18 +21,29 @@ function addFeedbackOrder() 'status' => 0, ]; save('feedbacks', $feedback_add); - echo "
Done! Thư phản hồi của bạn đã được gửi đến hệ thống của quán Chị Kòi. Cảm ơn bạn đã gửi lại phải hồi về quán.

Hãy đến Dashboard
"; - require('content/views/feedback/result.php'); - exit; } -function deleteFeedback($id) + +/** + * @param int $id + * + * @return void + */ +function deleteFeedback(int $id): void { - global $linkConnectDB; - $id = intval($id); - $sql = "DELETE FROM feedbacks WHERE id=$id"; - mysqli_query($linkConnectDB, $sql) or die(mysqli_error($linkConnectDB)); + $sql = "DELETE FROM feedbacks WHERE id = ?"; + + try { + $stmt = executeQuery($sql, [$id]); + $stmt->close(); + } catch (\Exception $e) { + die($e->getMessage()); + } } -function updateFeedback() + +/** + * @return void + */ +function updateFeedback(): void { $feedback = [ 'id' => intval($_POST['feedback_id']), @@ -81,25 +95,37 @@ function feedbackReplyMail($html, $email) echo 'Message could not be sent. Mailer Error: ', $mail->ErrorInfo; } } -function approveFeedback($id) + +/** + * @param int $id + * + * @return void + */ +function approveFeedback(int $id): void { - if (isset($_GET['feedback_id'])) { - $id = intval($_GET['feedback_id']); - } else { - show404NotFound(); + $sql = "UPDATE feedbacks SET status=1 where id= ?"; + + try { + $stmt = executeQuery($sql, [$id]); + $stmt->close(); + } catch (\Exception $e) { + die($e->getMessage()); } - global $linkConnectDB; - $sql = "UPDATE feedbacks SET status=1 where id=" . $id; - mysqli_query($linkConnectDB, $sql) or die(mysqli_error($linkConnectDB)); } -function unApproveFeedback($id) + +/** + * @param int $id + * + * @return void + */ +function unApproveFeedback(int $id): void { - if (isset($_GET['feedback_id'])) { - $id = intval($_GET['feedback_id']); - } else { - show404NotFound(); + $sql = "UPDATE feedbacks SET status=0 where id= ?"; + + try { + $stmt = executeQuery($sql, [$id]); + $stmt->close(); + } catch (\Exception $e) { + die($e->getMessage()); } - global $linkConnectDB; - $sql = "UPDATE feedbacks SET status=0 where id=" . $id; - mysqli_query($linkConnectDB, $sql) or die(mysqli_error($linkConnectDB)); } diff --git a/admin/models/media.php b/admin/models/media.php index 0fe7705..8e3aa7f 100644 --- a/admin/models/media.php +++ b/admin/models/media.php @@ -7,12 +7,6 @@ */ function mediaDestroy(int $id): void { - if (isset($_GET['media_id'])) { - $id = intval($_GET['media_id']); - } else { - show404NotFound(); - } - $media = getRecord('media', $id); $image = 'public/upload/media/' . $media['slug']; if (is_file($image)) { @@ -60,7 +54,7 @@ function mediaSave(array $data): void $slug = slug($_POST['name']); $config = [ 'name' => $slug, - 'upload_path' => '/public/upload/media/', + 'upload_path' => '../public/upload/media/', 'allowed_exts' => 'jpg|jpeg|png|gif', ]; $images = upload('imggggg', $config); diff --git a/admin/models/order.php b/admin/models/order.php index 31b8aa9..222105e 100644 --- a/admin/models/order.php +++ b/admin/models/order.php @@ -29,7 +29,11 @@ function orderDestroy($id) $sql = "DELETE FROM orders WHERE id=$id"; mysqli_query($linkConnectDB, $sql) or die(mysqli_error($linkConnectDB)); } -function orderComplete($id) + +/** + * @return void + */ +function orderComplete(): void { $id = intval($_POST['order_id']); $order = [ @@ -38,7 +42,11 @@ function orderComplete($id) ]; save('orders', $order); } -function orderInProcess($id) + +/** + * @return void + */ +function orderInProcess(): void { $id = intval($_POST['order_id']); $order = [ diff --git a/admin/views/feedback/add.php b/admin/views/feedback/add.php index 8d7c33b..e41755a 100644 --- a/admin/views/feedback/add.php +++ b/admin/views/feedback/add.php @@ -71,15 +71,15 @@ +$order_total = 0; +foreach ($orderDetail as $product) : + $stt++; + if ($product["product_typeid"] == 3) { + $order_total += ($product['product_price'] - (($product['product_price']) * ($product['percentoff']) / 100)) * $product['quantity']; + } else { + $order_total += $product['product_price'] * $product['quantity']; + } + ?> diff --git a/lib/counter.php b/lib/counter.php index fd8e163..47a39e8 100644 --- a/lib/counter.php +++ b/lib/counter.php @@ -1,7 +1,9 @@ $session, +]; +$count = getTotal('users_online', $options); + +if ($count == 0) { //Truy cập lần đầu insert_user_online($session, $time, $ip, $browser, $date); } else { //Truy cập lần 2 update_user_online($session, $time, $ip, $browser, $date); } + // $sql3 = "SELECT * FROM users_online"; // $result3 = mysqli_query($linkConnectDB, $sql3); // $count_user_online = mysqli_num_rows($result3); diff --git a/lib/functions.php b/lib/functions.php index 4b15f92..69d904f 100644 --- a/lib/functions.php +++ b/lib/functions.php @@ -1,5 +1,7 @@ '', @@ -232,3 +234,15 @@ function adminPagination(string $url, $page, $total): string $out .= ''; return $out; } + +/** + * @return void + */ +#[NoReturn] function dd(): void +{ + echo '
';
+    foreach (func_get_args() as $arg) {
+        var_dump($arg);
+    }
+    die;
+}