<?php
include 'includes/config.php';
session_start();

if (!$_SESSION['email']) {
    header('location:login.php');
}
?>
<?php
$sql = "SELECT * FROM units Where business_id = 3";
try {
    $query = $conn->prepare($sql);
    $query->execute();
    $space = $query->fetchAll();
} catch (Exception $ex) {
    echo ($ex->getMessage());
}
?>
<?php
$sql = "SELECT * FROM brands Where business_id = 3";
try {
    $query = $conn->prepare($sql);
    $query->execute();
    $brand = $query->fetchAll();
} catch (Exception $ex) {
    echo ($ex->getMessage());
}
?>
<?php


if ($_SERVER['REQUEST_METHOD'] === 'POST') {
    try {
        $product_id = $_POST['product_id'] ?? null;
        if (!$product_id) {
            throw new Exception('Product ID is missing.');
        }


        $name = $_POST['name'];
        $unit_id = $_POST['unit_id'];
        $brand_id = !empty($_POST['brand_id']) ? $_POST['brand_id'] : 0;
        $category_id = $_POST['category_id'];
        $sub_category_id = $_POST['sub_category_id'];
        $alert_quantity = $_POST['alert_quantity'];
        $default_purchase_price = $_POST['default_purchase_price'];
        $dpp_inc_tax = $_POST['dpp_inc_tax'];
        $profit_percent = $_POST['profit_percent'];
        $default_sell_price = $_POST['default_sell_price'];
        $product_description = $_POST['product_description'];
        $weight = $_POST['weight'];
        $color_id = $_POST['color_id'];
        $size_id = $_POST['size_id'];
        $product_code = $_POST['product_code'];
        $barcode = $_POST['barcode'];
        $serial_no = $_POST['serial_no'] ?? '';
        $model_no = $_POST['model_no'] ?? '';


        $imageName = $_POST['old_image'] ?? '';
        if (isset($_FILES['image']) && $_FILES['image']['error'] == 0) {
            $imageTmpName = $_FILES['image']['tmp_name'];
            $imageOriginalName = $_FILES['image']['name'];
            $imageExtension = pathinfo($imageOriginalName, PATHINFO_EXTENSION);
            $uniqueId = uniqid();
            $imageName = $uniqueId . '.' . $imageExtension;
            if (!move_uploaded_file($imageTmpName, 'img/' . $imageName)) {
                throw new Exception('Failed to move uploaded file.');
            }
        }


        $stmt = $conn->prepare("SELECT COUNT(*) FROM products WHERE barcode = ? AND id != ?");
        $stmt->execute([$barcode, $product_id]);
        if ($stmt->fetchColumn() > 0) {
            throw new Exception('This barcode is already assigned to another product.');
        }

        // Update products table
        $sql = "UPDATE products 
                SET name = ?, unit_id = ?, brand_id = ?, category_id = ?, sub_category_id = ?, 
                    alert_quantity = ?, image = ?, product_description = ?, weight = ?, 
                    color_id = ?, size_id = ?, product_code = ?, barcode = ?, serial_no = ?, model_no = ? 
                WHERE id = ?";
        $stmt = $conn->prepare($sql);
        if (!$stmt->execute([
            $name,
            $unit_id,
            $brand_id,
            $category_id,
            $sub_category_id,
            $alert_quantity,
            $imageName,
            $product_description,
            $weight,
            $color_id,
            $size_id,
            $product_code,
            $barcode,
            $serial_no,
            $model_no,
            $product_id
        ])) {
            throw new Exception('Failed to execute update query: ' . implode(", ", $stmt->errorInfo()));
        }

        //  if ($stmt->rowCount() === 0) {
        // throw new Exception('No rows updated. Please check if the data is correctly passed.');
        // }


        if (!empty($brand_id)) {
            $stmt = $conn->prepare("SELECT name FROM brands WHERE id = ?");
            if ($stmt->execute([$brand_id])) {
                $brand = $stmt->fetch(PDO::FETCH_ASSOC);
                if ($brand && !empty($brand['name'])) {
                    $sku = $brand['name'] . $product_id;

                    $sql = "UPDATE products SET sku = ? WHERE id = ?";
                    $stmt = $conn->prepare($sql);
                    $stmt->execute([$sku, $product_id]);
                }
            }
        }



        $sql = "UPDATE variations 
                SET default_purchase_price = ?, dpp_inc_tax = ?, profit_percent = ?, 
                    default_sell_price = ?, sell_price_inc_tax = ? 
                WHERE product_id = ?";
        $stmt = $conn->prepare($sql);
        if (!$stmt->execute([$default_purchase_price, $dpp_inc_tax, $profit_percent, $default_sell_price, $default_sell_price, $product_id])) {
            throw new Exception('Failed to execute variations update query: ' . implode(", ", $stmt->errorInfo()));
        }

        echo "<script>
            alert('Data updated successfully');
            window.location.href = 'list_products.php';
        </script>";
    } catch (Exception $e) {
        file_put_contents('error_log.txt', $e->getMessage() . PHP_EOL, FILE_APPEND);
        echo "<script>alert('Error: " . $e->getMessage() . "');</script>";
    }
}
?>




<!doctype html>
<html lang="en">

<head>
    <!-- Required meta tags -->
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <title>Edit Products</title>
    <!-- Favicon -->
    <link rel="shortcut icon" href="images/favicon.ico" />
    <!-- Bootstrap CSS -->
    <link rel="stylesheet" href="css/bootstrap.min.css">
    <!-- Typography CSS -->
    <link rel="stylesheet" href="css/typography.css">
    <!-- Style CSS -->
    <link rel="stylesheet" href="css/style.css">
    <!-- Responsive CSS -->
    <link rel="stylesheet" href="css/responsive.css">
    <script src="https://cdn.tiny.cloud/1/x0knnqxecmgjit09cwg7e45mjj82ys2ycfjxxa9112rc8i57/tinymce/5/tinymce.min.js"></script>

    <style>
        ion-icon {
            font-size: 20px;
            margin-bottom: -5px;
        }
    </style>

</head>

<body>
    <!-- loader Start -->
    <div id="loading">
        <div id="loading-center">
        </div>
    </div>
    <!-- loader END -->
    <!-- Wrapper Start -->
    <div class="wrapper">
        <!-- Sidebar  -->
        <?php
        include 'includes/sidebar.php';
        ?>
        <!-- TOP Nav Bar -->
        <?php include 'includes/header.php'; ?>
        <!-- TOP Nav Bar END -->
        <!-- Page Content  -->
        <!-- Modal HTML -->
        <div class="modal fade" id="addUnitModal" tabindex="-1" role="dialog" aria-labelledby="addUnitModalLabel" aria-hidden="true">
            <div class="modal-dialog" role="document">
                <div class="modal-content">
                    <div class="modal-header">
                        <h5 class="modal-title" id="addUnitModalLabel">Add New Unit</h5>
                        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                            <span aria-hidden="true">&times;</span>
                        </button>
                    </div>
                    <form id="insertForm" method="post" action="insert_unit_data.php">
                        <div class="modal-body">
                            <div class="form-group">
                                <label for="actual_name" class="control-label">Name</label>
                                <input type="text" name="actual_name" class="form-control" placeholder="Name" id="actual_name" required>
                            </div>
                            <div class="form-group">
                                <label for="short_name" class="control-label">Short Name</label>
                                <input type="text" name="short_name" class="form-control" placeholder="Short Name" id="short_name" required>
                            </div>
                            <div class="form-group">
                                <label for="allow_decimal" class="control-label">Allow Decimal</label>
                                <select name="allow_decimal" class="form-control" id="allow_decimal" required>
                                    <option value="">Please select</option>
                                    <option value="1">Yes</option>
                                    <option value="0">No</option>
                                </select>
                            </div>
                            <div class="form-group">
                                <input type="checkbox" name="add_multiple" id="add_multiple">
                                <label for="add_multiple">Add as multiple of other unit</label>
                            </div>
                        </div>
                        <div class="modal-footer">
                            <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
                            <button type="submit" class="btn btn-primary">Save</button>
                        </div>
                    </form>
                </div>
            </div>
        </div>


        <!-- Bootstrap CSS -->
        <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">

        <!-- Font Awesome CSS -->
        <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css">

        <!-- jQuery -->
        <script src="https://code.jquery.com/jquery-3.5.1.slim.min.js"></script>

        <!-- Bootstrap JS -->
        <script src="https://cdn.jsdelivr.net/npm/bootstrap@4.5.2/dist/js/bootstrap.bundle.min.js"></script>

        <div id="content-page" class="content-page">
            <div class="container-fluid">
                <div class="row">
                    <div class="col-sm-12">
                        <div class="iq-card">
                            <div class="iq-card-header d-flex justify-content-between row">
                                <div class="iq-header-title col-lg-6">
                                    <h4 class="card-title"><a href="list_products.php">Products</a> > Add Products
                                    </h4>
                                </div>
                            </div>
                           <?php 
$product_id = isset($_GET['product_id']) ? intval($_GET['product_id']) : 0;
$product = null;

if ($product_id > 0) {
    try {
        $sql = "SELECT 
            p.id, 
            p.name, 
            p.serial_no,
            p.model_no,
            p.barcode,
            p.unit_id, 
            p.category_id, 
            p.sub_category_id, 
            p.brand_id, 
            b.name AS brand_name,       
            p.tax_type, 
            p.product_code,
            p.alert_quantity, 
            p.sku, 
            p.barcode_type, 
            p.image, 
            p.weight,
            p.product_description, 
            p.color_id, 
            p.size_id,
            u.actual_name AS unit_name, 
            c1.name AS category_name, 
            c2.name AS sub_category_name,
            clr.product_color,
            sz.product_size,
            v.product_id AS variation_product_id, 
            v.default_purchase_price, 
            v.dpp_inc_tax, 
            v.profit_percent, 
            v.default_sell_price, 
            v.sell_price_inc_tax
        FROM products p
        LEFT JOIN units u ON p.unit_id = u.id
        LEFT JOIN categories c1 ON p.category_id = c1.id
        LEFT JOIN categories c2 ON p.sub_category_id = c2.id
        LEFT JOIN colors clr ON p.color_id = clr.id
        LEFT JOIN sizes sz ON p.size_id = sz.id
        LEFT JOIN variations v ON p.id = v.product_id
        LEFT JOIN brands b ON p.brand_id = b.id     
        WHERE p.id = :product_id";

        $stmt = $conn->prepare($sql);
        $stmt->bindParam(':product_id', $product_id, PDO::PARAM_INT);
        $stmt->execute();
        $product = $stmt->fetch(PDO::FETCH_ASSOC);
    } catch (PDOException $e) {
        echo "Error: " . $e->getMessage();
    }
} else {
    echo "Invalid product ID.";
}
?>


                            <div class="iq-card-body" style="overflow:auto;">
                                <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" enctype="multipart/form-data">
                                    <div class="row">

                                        <div class="col-lg-4">
                                            <div class="form-group">
                                                <label class="label-control">Product Name:*</label>
                                                <input type="hidden" class="form-control" name="product_id"
                                                    value="<?php echo htmlspecialchars($product['id']); ?>">
                                                <input type="text" class="form-control" name="name" placeholder="Please Enter Product Name" value="<?php echo htmlspecialchars($product['name']); ?>">
                                                <small id="name_error" class="text-danger"></small>
                                            </div>
                                        </div>

                                        <div class="col-lg-4">
                                            <div class="form-group">
                                                <label class="label-control">Product Code:*</label>
                                                <input type="text" class="form-control" name="product_code" value="<?php echo htmlspecialchars($product['product_code']); ?>" id="product_code"
                                                    placeholder="Please Enter Product Code" required>
                                                <small id="code_error" class="text-danger"></small>
                                            </div>
                                        </div>


                                        <div class="col-lg-4" style="display: none;">
                                            <div class="form-group">
                                                <label class="label-control">Product Color:*</label>
                                                <div class="input-group">
                                                    <select name="color_id" id="color_id" class="form-control" required>
                                                        <option disabled <?php echo empty($product['color_id']) ? 'selected' : ''; ?>>Please Select</option>
                                                        <?php
                                                        $stmt = $conn->query("SELECT id, product_color FROM colors ORDER BY product_color ASC");
                                                        while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
                                                            $selected = ($product['color_id'] == $row['id']) ? 'selected' : '';
                                                            echo "<option value='{$row['id']}' $selected>" . htmlspecialchars($row['product_color']) . "</option>";
                                                        }
                                                        ?>
                                                    </select>
                                                </div>
                                            </div>
                                        </div>
                                        <div class="col-lg-4">
                                            <div class="form-group">
                                                <label class="label-control">Bar Code:*</label>
                                                <input type="text" id="barcode" name="barcode" value="<?php echo htmlspecialchars($product['barcode']); ?>" class="form-control" required>
                                                <small id="barcode_error" style="color:red;"></small>

                                            </div>
                                        </div>


                                        <div class="col-lg-4" style="display: none;">
                                            <div class="form-group">
                                                <label class="label-control">Serial No:*</label>
                                                <input type="text" id="serial_no" name="serial_no" value="<?php echo htmlspecialchars($product['serial_no']); ?>" class="form-control">
                                                <small id="serial_no_error" style="color:red;"></small>

                                            </div>
                                        </div>

                                        <div class="col-lg-4" style="display: none;">
                                            <div class="form-group">
                                                <label class="label-control">Model No:*</label>
                                                <input type="text" id="model_no" name="model_no" value="<?php echo htmlspecialchars($product['model_no']); ?>" class="form-control">
                                                <small id="model_no_error" style="color:red;"></small>

                                            </div>
                                        </div>


                                        <div class="col-lg-4" style="display: none;">
                                            <div class="form-group">
                                                <label class="label-control">Product Size:*</label>
                                                <div class="input-group">
                                                    <select name="size_id" id="size_id" class="form-control" required>
                                                        <option disabled <?php echo empty($product['size_id']) ? 'selected' : ''; ?>>Please Select</option>
                                                        <?php
                                                        $stmt = $conn->query("SELECT id, product_size FROM sizes ORDER BY product_size ASC");
                                                        while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
                                                            $selected = ($product['size_id'] == $row['id']) ? 'selected' : '';
                                                            echo "<option value='{$row['id']}' $selected>" . htmlspecialchars($row['product_size']) . "</option>";
                                                        }
                                                        ?>
                                                    </select>
                                                </div>
                                            </div>
                                        </div>

                                        <div class="col-lg-6">
                                            <div class="form-group">
                                                <label for="unit_id" class="label-control mr-2">Unit:*</label>
                                                <div class="input-group">
                                                    <select name="unit_id" class="form-control" id="unit_id" required>
                                                        <option value="<?php echo htmlspecialchars($product['unit_id']); ?>"><?php echo htmlspecialchars($product['unit_name']); ?></option>

                                                        <?php foreach ($space as $output) { ?>
                                                            <option value="<?php echo htmlspecialchars($output["id"], ENT_QUOTES); ?>">
                                                                <?php echo htmlspecialchars($output["actual_name"], ENT_QUOTES); ?> ( <?php echo htmlspecialchars($output["short_name"], ENT_QUOTES); ?> )
                                                            </option>
                                                        <?php } ?>
                                                    </select>
                                                    <div class="input-group-append">
                                                        <button class="btn btn-outline-secondary" type="button" data-toggle="modal" data-target="#addUnitModal">
                                                            <i class="fa fa-plus"></i>
                                                        </button>
                                                    </div>
                                                </div>
                                            </div>

                                        </div>
                                        <div class="col-lg-6">
                                            <div class="form-group">
                                                <label for="" class="label-control">Brand:*</label>
                                                <div class="input-group">
                                                    <select name="brand_id" class="form-control" required>
    <?php foreach ($brand as $output) { ?>
        <option value="<?php echo htmlspecialchars($output["id"], ENT_QUOTES); ?>" 
            <?php echo ($output["id"] == $product['brand_id']) ? 'selected' : ''; ?>>
            <?php echo htmlspecialchars($output["name"], ENT_QUOTES); ?>
        </option>
    <?php } ?>
</select>

                                                    <div class="input-group-append">
                                                        <button class="btn btn-outline-secondary" type="button" data-toggle="modal" data-target="#addUnitModal">
                                                            <i class="fa fa-plus"></i>
                                                        </button>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                        <script src="https://code.jquery.com/jquery-3.5.1.min.js"></script>

                                        <div class="col-lg-6">
                                            <div class="form-group">
                                                <label for="category" class="label-control">Category:*</label>
                                                <select name="category_id" class="form-control" id="category" required>
                                                    <option value="<?php echo htmlspecialchars($product['category_id']); ?>">
                                                        <?php echo htmlspecialchars($product['category_name']); ?>
                                                    </option>
                                                    <?php
                                                    $business_id = 3;
                                                    $stmt = $conn->prepare("SELECT id, name FROM categories WHERE parent_id = 0 AND business_id = ?");
                                                    $stmt->execute([$business_id]);

                                                    while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
                                                        echo '<option value="' . $row['id'] . '">' . $row['name'] . '</option>';
                                                    }
                                                    ?>
                                                </select>

                                            </div>
                                        </div>

                                        <div class="col-lg-6" style="display: none;">
                                            <div class="form-group">
                                                <label for="subcategory" class="label-control">Sub category:*</label>
                                                <select name="sub_category_id" class="form-control" id="subcategory">
                                                    <option value="<?php echo htmlspecialchars($product['sub_category_id']); ?>"><?php echo htmlspecialchars($product['sub_category_name']); ?></option>

                                                </select>
                                            </div>
                                        </div>

                                        <div class="col-lg-6">
                                            <div class="form-group">
                                                <label for="" class="label-control">Alert quantity:*</label>
                                                <input type="number" class="form-control" value="<?php echo htmlspecialchars($product['alert_quantity']); ?>" name="alert_quantity"
                                                    placeholder="Alert quantity" id="">
                                            </div>
                                        </div>

                                        <div class="col-lg-6" style="display: none;">
                                            <div class="form-group">
                                                <label for="" class="label-control">Weight:</label>
                                                <input type="number" class="form-control" value="<?php echo htmlspecialchars($product['weight']); ?>" name="weight"
                                                    placeholder="Alert quantity" id="">
                                            </div>
                                        </div>
                                        <div class="col-lg-6">
                                        </div>
                                        <div class="col-lg-6" style="display:none;">
                                            <div class="form-group">
                                                <label for="" class="label-control">Product Description:</label>

                                                <textarea id="editor" name="product_description"><?php echo htmlspecialchars($product['product_description']); ?></textarea>

                                                <!-- Input field for image upload -->

                                                <input type="file" id="imageInput" accept="image/*" style="display: none;">
                                                <label for="imageInput" style="cursor: pointer; display:none;">Upload Image</label>
                                            </div>
                                        </div>

                                        <div class="iq-card-body" style="overflow:auto;">
                                            <table class="table table-hover table-bordered">
                                                <thead>
                                                    <tr>
                                                        <!-- <th colspan="2">Default Purchase Price</th>
                                                        <th>x Margin (%)</th> -->
                                                        <th>Default Purchse Price</th>
                                                        <th>Default Selling Price</th>
                                                        <th>Product Image</th>
                                                    </tr>
                                                </thead>
                                                <tbody>
                                                    <tr>

                                                        <td style="display: none;">
                                                            <div class="form-group">
                                                                <label for="purchasePriceIncTax" class="label-control">Inc. tax:</label>
                                                                <input type="text" class="form-control" value="<?php echo htmlspecialchars($product['dpp_inc_tax']); ?>" name="dpp_inc_tax" id="purchasePriceIncTax" placeholder="Inc. tax" readonly>
                                                            </div>
                                                        </td>
                                                        <td style="display: none;">
                                                            <div class="form-group">
                                                                <label for="margin" class="label-control">Margin (%)</label>
                                                                <input type="text" class="form-control" id="margin" value="<?php echo htmlspecialchars($product['profit_percent']); ?>" name="profit_percent" placeholder="0.00" required oninput="calculatePurchasePrice()">
                                                            </div>
                                                        </td>
                                                        <td>
                                                            <div class="form-group">
                                                                <label for="purchasePriceExcTax" class="label-control">Purchse Price:</label>
                                                                <input type="text" class="form-control" value="<?php echo htmlspecialchars($product['default_purchase_price']); ?>" name="default_purchase_price" id="purchasePriceExcTax" placeholder="Exc. tax">
                                                            </div>
                                                        </td>
                                                        <td>
                                                            <div class="form-group">
                                                                <label for="sellingPrice" class="label-control">Selling Price:</label>
                                                                <input type="text" class="form-control" id="sellingPrice" value="<?php echo htmlspecialchars($product['default_sell_price']); ?>" name="default_sell_price" placeholder="Exc. tax" required>
                                                            </div>
                                                        </td>

                                                        <td>
                                                           <div class="form-group">
    <label for="productImage" class="label-control">Attach Document:</label>
    <?php if(!empty($product['image'])): ?>
        <br>
        <img src="img/<?php echo htmlspecialchars($product['image']); ?>" 
             alt="Current Image" 
             style="max-width: 80px; max-height: 80px; margin-bottom: 5px; display:block;">
    <?php endif; ?>
    <input type="hidden" id="imageInput" name="old_image" value="<?php echo htmlspecialchars($product['image']); ?>">
    <input type="file" class="form-control" name="image" id="productImage">
</div>

                                                        </td>
                                                    </tr>
                                                </tbody>
                                            </table>

                                        </div>
                                        <div class="col-lg-12">
                                            <button class="btn btn-primary">Submit</button>
                                        </div>
                                    </div>
                                </form>
                            </div>
                        </div>
                    </div>
                </div>
            </div>

        </div>
    </div>
    </div>
    <script>
        function calculatePurchasePrice() {
            // Get values from input fields
            var sellingPrice = parseFloat(document.getElementById('sellingPrice').value) || 0;
            var margin = parseFloat(document.getElementById('margin').value) || 0;

            // Calculate the purchase price (Exc. tax)
            var purchasePrice = sellingPrice / (1 + (margin / 100));

            // Update both purchase price fields to show the same value
            document.getElementById('purchasePriceExcTax').value = purchasePrice.toFixed(2);
            document.getElementById('purchasePriceIncTax').value = purchasePrice.toFixed(2);
        }
    </script>
    <script>
        $(document).ready(function() {
            $('#category').change(function() {
                var categoryId = $(this).val();

                if (categoryId) {
                    $.ajax({
                        url: 'fetch_subcategories.php',
                        type: 'POST',
                        data: {
                            id: categoryId
                        },
                        dataType: 'json',
                        success: function(response) {
                            $('#subcategory').empty();
                            $('#subcategory').append('<option value="">Please Select</option>');
                            $.each(response, function(index, subcategory) {
                                $('#subcategory').append('<option value="' + subcategory.id + '">' + subcategory.name + '</option>');
                            });
                        }
                    });
                } else {
                    $('#subcategory').empty();
                    $('#subcategory').append('<option value="">Please Select</option>');
                }
            });
        });
    </script>
    <!-- Wrapper END -->
    <!-- Footer -->
    <?php include 'includes/footer.php'; ?>
    <nav class="iq-float-menu">
        <input type="checkbox" href="#" class="iq-float-menu-open" name="menu-open" id="menu-open" />
        <label class="iq-float-menu-open-button" for="menu-open">
            <span class="lines line-1"></span>
            <span class="lines line-2"></span>
            <span class="lines line-3"></span>
        </label>
        <button class="iq-float-menu-item bg-info" data-toggle="tooltip" data-placement="top" title="Direction Mode"
            data-mode="rtl"><i class="ri-text-direction-r"></i></button>
        <button class="iq-float-menu-item bg-danger" data-toggle="tooltip" data-placement="top" title="Color Mode"
            id="dark-mode" data-active="true"><i class="ri-sun-line"></i></button>
        <button class="iq-float-menu-item bg-warning" data-toggle="tooltip" data-placement="top" title="Comming Soon"><i
                class="ri-palette-line"></i></button>
    </nav>
    <!-- Footer END -->
    <!-- Optional JavaScript -->
    <!-- jQuery first, then Popper.js, then Bootstrap JS -->
    <script src="js/jquery.min.js"></script>
    <!-- Rtl and Darkmode -->
    <script src="js/rtl.js"></script>
    <script src="js/customizer.js"></script>
    <script src="js/popper.min.js"></script>
    <script src="js/bootstrap.min.js"></script>
    <!-- Appear JavaScript -->
    <script src="js/jquery.appear.js"></script>
    <!-- Countdown JavaScript -->
    <script src="js/countdown.min.js"></script>
    <!-- Counterup JavaScript -->
    <script src="js/waypoints.min.js"></script>
    <script src="js/jquery.counterup.min.js"></script>
    <!-- Wow JavaScript -->
    <script src="js/wow.min.js"></script>
    <!-- Apexcharts JavaScript -->
    <script src="js/apexcharts.js"></script>
    <!-- Slick JavaScript -->
    <script src="js/slick.min.js"></script>
    <!-- Select2 JavaScript -->
    <script src="js/select2.min.js"></script>
    <!-- Owl Carousel JavaScript -->
    <script src="js/owl.carousel.min.js"></script>
    <!-- Magnific Popup JavaScript -->
    <script src="js/jquery.magnific-popup.min.js"></script>
    <!-- Smooth Scrollbar JavaScript -->
    <script src="js/smooth-scrollbar.js"></script>
    <!-- lottie JavaScript -->
    <script src="js/lottie.js"></script>
    <!-- Chart Custom JavaScript -->
    <script src="js/chart-custom.js"></script>
    <!-- Custom JavaScript -->
    <script src="js/custom.js"></script>
</body>

</html>