CAFECODEFILE
CAFECODEFILE
HTML:
<!DOCTYPE html>
<html>
<head>
<title>{% block head_title %}{% endblock %}</title>
<link
href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.1/dist/css/bootstrap.min.css"
rel="stylesheet" integrity="sha384-
+0n0xVW2eSR5OomGNYDnhzAbDsOXxcvSN1TPprVMTNDbiYZCxYbOOl
7+AMvyTG2x" crossorigin="anonymous">
<style>
.form-group {
margin-top: 10px;
}
</style>
{% block extra_head %}
{% endblock %}
</head>
<body>
{% block body %}
{% if messages %}
<div class="p-2">
{% for message in messages %}
<div class="text-center border-bottom">{{message}}</div>
{% endfor %}
</div>
{% endif %}
<div class="p-3 mb-3 bg-dark">
<div class="container d-flex justify-content-between">
{% if user.is_authenticated %}
<div><a class="text-light" href="{% url 'account_email' %}">Change E-
mail</a></div>
<div><a class="text-light" href="{% url 'home' %}">Home</a></div>
<div><a class="text-light" href="{% url 'account_logout' %}">Sign
Out</a></div>
{% else %}
<div><a class="text-light" href="{% url 'account_login' %}">Sign
In</a></div>
<div><a class="text-light" href="{% url 'account_signup' %}">Sign
Up</a></div>
{% endif %}
</div>
</div>
{% block content %}
{% endblock %}
{% endblock %}
{% block extra_body %}
{% endblock %}
<script
src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.1/dist/js/bootstrap.bundle.min.j
s"
integrity="sha384-gtEjrD/SeCtmISkJkNUaaKMoLD0//ElJ19smozuHV6z3Iehd
s+3Ulb9Bn9Plx0x4" crossorigin="anonymous"></script>
</body>
</html>
LOGIN.HTML:
{% extends "account/base.html" %}
{% load i18n %}
{% load account socialaccount %}
{% load crispy_forms_filters %}
{% block content %}
<div class="text-center">
<h1>{% trans "Sign In" %}</h1>
{% get_providers as socialaccount_providers %}
{% if socialaccount_providers %}
<p>{% blocktrans with site.name as site_name %}Please sign in with one
of your existing third party accounts.<br>Or, <a href="{{ signup_url }}">sign
up</a>
for a {{ site_name }} account and sign in below:{% endblocktrans %}</p>
<div class="socialaccount_ballot">
<div class="socialaccount_providers">
{% include "socialaccount/snippets/provider_list.html" with process="login"
%}
</div>
</div>
{% include "socialaccount/snippets/login_extra.html" %}
{% else %}
<p>{% blocktrans %}If you have not created an account yet, then please
<a href="{{ signup_url }}">sign up</a> first.{% endblocktrans %}</p>
{% endif %}
</div>
<div class="row">
<div class="col-md-6 offset-md-3">
<form class="login" method="POST" action="{% url 'account_login' %}">
{% csrf_token %}
{% if redirect_field_value %}
<input type="hidden" name="{{ redirect_field_name }}"
value="{{ redirect_field_value }}" />
{% endif %}
<div class="d-grid">
<button class="primaryAction mt-3 btn btn-dark" type="submit">{% trans
"Sign In" %}</button><br>
<a class="button secondaryAction text-dark text-center" href="{% url
'account_reset_password' %}">{% trans "Forgot Password?" %}</a>
</div>
</form>
</div>
</div>
{% endblock %}
SIGNUP.HTML:
{% extends "account/base.html" %}
{% load i18n %}
{% load crispy_forms_filters %}
{% block content %}
<div class="text-center">
<h1>{% trans "Sign Up" %}</h1>
ADD CATEGORY.HTML:
{% extends 'admin/base.html' %}
{% block title %}
Add Category
{% endblock %}
{% block breadcrumb %}
<div class="row mb-4 mt-2" style="height: 110px; background: linear-
gradient(90deg, #4B4B4B, #2C3E50);">
<div class="col-lg-8 mt-5">
<h2 style="font-size: 28px;font-weight: 700;color: #ffffff;" class="ml-
5"><b>Add Category</b></h2>
</div>
<div class="col-lg-3 mt-4">
<ul class="breadcrumb" style="background-color: #06A245;">
<li class="breadcrumb-item"><a href="{% url 'admin_page'
%}"><b>Admin</b></a></li>
<li class="breadcrumb-item"><a href="{% url 'categories'
%}"><b>Category</b></a></li>
<li style="color: rgb(187, 186, 183);" class="breadcrumb-item active"><b>Add
category</b></li>
</ul>
</div>
</div>
{% endblock %}
{% block content %}
<div class="container mt-4">
<div class="row justify-content-center">
<div class="col-md-8">
<form method="post" enctype="multipart/form-data" id="category-form">
{% csrf_token %}
</div>
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
<script
src="https://cdnjs.cloudflare.com/ajax/libs/cropperjs/1.5.11/cropper.min.js"></
script>
<script>
// Function to preview selected image
function readURL(input) {
if (input.files && input.files[0]) {
var reader = new FileReader();
reader.onload = function(e) {
$('#blah').attr('src', e.target.result);
setTimeout(initCropper, 1000); // Initialize Cropper after image is loaded
};
reader.readAsDataURL(input.files[0]);
}
}
$.ajax({
url: '{% url "create_category" %}',
method: 'POST',
data: formData,
processData: false,
contentType: false,
success: function(response) {
Swal.fire({
title: 'Success!',
text: response.message,
icon: 'success',
showConfirmButton: false,
timer: 1500
}).then(() => {
window.location.href = '{% url "categories" %}'; // Redirect to categories page
after success
});
},
error: function(xhr, status, error) {
Swal.fire({
title: 'Error!',
text: 'An error occurred while creating the category.',
icon: 'error',
showConfirmButton: true
});
}
});
});
</script>
{% endblock %}
ADD PRODUCT.HTML:
{% extends 'admin/base.html' %}
{% block breadcrumb %}
<div class="row mb-4 mt-2" style="height: 110px; background: linear-
gradient(90deg, #4B4B4B, #2C3E50);">
<div class="col-lg-8 mt-5">
<h2 style="font-size: 28px;font-weight: 700;color: #ffffff;" class="ml-
5"><b>Add Product</b></h2>
</div>
<div class="col-lg-3 mt-4">
<ul class="breadcrumb" style="background-color: #06A245;">
<li class="breadcrumb-item"><a href="{% url 'admin_page'
%}"><b>Admin</b></a></li>
<li class="breadcrumb-item"><a href="{% url 'products'
%}"><b>Product</b></a></li>
<li style="color: rgb(187, 186, 183);" class="breadcrumb-item active"><b>Add
product</b></li>
</ul>
</div>
</div>
{% endblock %}
{% block content %}
<div class="container mt-4">
<div class="row justify-content-center">
<div class="col-md-10">
checkbox.addEventListener('change', function() {
quantityInput.disabled = !this.checked;
if (!this.checked) {
quantityInput.value = ''; // Reset quantity input when checkbox is unchecked
}
});
// Initialize the state of the quantity input based on whether the checkbox is
checked
quantityInput.disabled = !checkbox.checked;
});
});
</script>
{% endblock %}
PRODUCT.HTML:
{% extends 'admin/base.html' %}
{% block title %}
Admin Panel
{% endblock %}
{% block breadcrumb %}
<div class="row mb-4 mt-2" style="height: 110px; background: linear-
gradient(90deg, #4B4B4B, #2C3E50);">
<div class="col-lg-8 mt-5">
<h2 style="font-size: 28px;font-weight: 700;color: #ffffff;" class="ml-
5"><b>Products</b></h2>
</div>
<div class="col-lg-2 mt-4">
<ul class="breadcrumb" style="background-color: #06A245;">
<li class="breadcrumb-item"><a href="{% url 'admin_page'
%}"><b>Admin</b></a></li>
<li style="color: rgb(187, 186, 183);" class="breadcrumb-item
active"><b>Products</b></li>
</ul>
</div>
<div class="col-2 mt-4">
<a href="{% url 'add_product' %}" style="border-radius: .375rem;" class="btn
hvr-hover mt-2">Add Product</a>
</div>
</div>
{% endblock %}
{% block content %}
<div class="container">
<table class="table">
<thead style="color: white; background-color: #7755A2;">
<tr>
<th scope="col">Name</th>
<th scope="col">Category</th>
<th scope="col">Price</th>
<th scope="col">Discount</th>
<th scope="col">Selling Price</th>
<th scope="col">Quantity</th>
<th scope="col">Action</th>
</tr>
</thead>
<tbody id="product-table-body">
{% for product in products %}
<tr class="table-success">
<td>
<div>{{ product.name }}</div>
<div>
<img src="{{ product.primary_image.url }}" alt="{{ product.name }}"
style="max-width: 80px;">
{% for image in product.secondaryimage_set.all %}
<img src="{{ image.image.url }}" alt="{{ product.name }}" class="img-
thumbnail" style="max-width: 50px;">
{% endfor %}
</div>
</td>
<td>{{ product.category }}</td>
<td>{{ product.price }}</td>
<td>{{ product.discount }}</td>
<td>{{ product.selling_price }}</td>
<td>
<div class="dropdown show">
<a class="btn btn-secondary dropdown-toggle" href="#" role="button"
id="dropdownMenuLink" data-toggle="dropdown" aria-haspopup="true" aria-
expanded="false">
{{ product.total_quantity }}
</a>
<div class="dropdown-menu" aria-labelledby="dropdownMenuLink">
<table class="table table-bordered">
<thead>
<tr>
<th>Location</th>
<th>Quantity</th>
</tr>
</thead>
<tbody>
{% for product_location in product.productlocations_set.all %}
<tr>
<td>{{ product_location.location.name }}</td>
<td>{{ product_location.quantity }}</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
</td>
<td>
<a href="{% url 'edit_product' product.id %}" class="btn hvr-hover"><i
class="fa-regular fa-pen-to-square"></i></a>
<a style="background-color: red;" href="{% url 'delete_product' product.id %}"
class="btn hvr-hover"><i class="fa-solid fa-trash"></i></a>
</td>
</tr>
{% endfor %}
</tbody>
</table>
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<script>
$(document).ready(function(){
const itemsPerPage = 4;
const $productTableBody = $('#product-table-body');
const $paginationControls = $('#pagination-controls');
const $productRows = $productTableBody.children('tr');
const totalItems = $productRows.length;
const totalPages = Math.ceil(totalItems / itemsPerPage);
function showPage(page) {
const start = (page - 1) * itemsPerPage;
const end = start + itemsPerPage;
$productRows.hide();
$productRows.slice(start, end).show();
$paginationControls.empty();
if (page > 1) {
$paginationControls.append(`<li class="page-item"><a class="page-link"
href="#" data-page="${page - 1}">«</a></li>`);
} else {
$paginationControls.append(`<li class="page-item disabled"><span
class="page-link">«</span></li>`);
}
showPage(1);
});
</script>
{% endblock %}
EDIT_CATEGORY.HTML:
{% extends 'admin/base.html' %}
{% block breadcrumb %}
<div class="row mb-4 mt-2" style="height: 110px; background: linear-
gradient(90deg, #4B4B4B, #2C3E50);">
<div class="col-lg-8 mt-5">
<h2 style="font-size: 28px;font-weight: 700;color: #ffffff;" class="ml-
5"><b>Edit Category</b></h2>
</div>
<div class="col-lg-3 mt-4">
<ul class="breadcrumb" style="background-color: #06A245;">
<li class="breadcrumb-item"><a href="{% url 'admin_page'
%}"><b>Admin</b></a></li>
<li class="breadcrumb-item"><a href="{% url 'categories'
%}"><b>Category</b></a></li>
<li style="color: rgb(187, 186, 183);" class="breadcrumb-item active"><b>Edit
category</b></li>
</ul>
</div>
</div>
{% endblock %}
{% block content %}
<div class="container">
<div class="row justify-content-center">
<div class="col-md-8">
<form method="post" enctype="multipart/form-data">
{% csrf_token %}
<div class="form-group">
{{ form.name.label_tag }}
{{ form.name }}
{% if form.name.errors %}
<div class="alert alert-danger">
{% for error in form.name.errors %}
<p>{{ error }}</p>
{% endfor %}
</div>
{% endif %}
</div>
<div class="form-group">
{{ form.image.label_tag }}
{{ form.image }}
{% if form.image.errors %}
<div class="alert alert-danger">
{% for error in form.image.errors %}
<p>{{ error }}</p>
{% endfor %}
</div>
{% endif %}
</div>
<div class="form-group">
{{ form.description.label_tag }}
{{ form.description }}
{% if form.description.errors %}
<div class="alert alert-danger">
{% for error in form.description.errors %}
<p>{{ error }}</p>
{% endfor %}
</div>
{% endif %}
</div>
<button style="border-radius: .375rem;" type="submit" class="btn hvr-
hover">Save changes</button>
</form>
</div>
</div>
</div>
{% endblock %}
EDIT_PRODUCT.HMTL:
{% extends 'admin/base.html' %}
{% block breadcrumb %}
<div class="row mb-4 mt-2" style="height: 110px; background: linear-
gradient(90deg, #4B4B4B, #2C3E50);">
<div class="col-lg-8 mt-5">
<h2 style="font-size: 28px;font-weight: 700;color: #ffffff;" class="ml-
5"><b>Edit Product</b></h2>
</div>
<div class="col-lg-3 mt-4">
<ul class="breadcrumb" style="background-color: #06A245;">
<li class="breadcrumb-item"><a href="{% url 'admin_page'
%}"><b>Admin</b></a></li>
<li class="breadcrumb-item"><a href="{% url 'products'
%}"><b>Product</b></a></li>
<li style="color: rgb(187, 186, 183);" class="breadcrumb-item active"><b>Edit
product</b></li>
</ul>
</div>
</div>
{% endblock %}
{% block content %}
<div class="container mt-4">
<div class="row justify-content-center">
<div class="col-md-10">
<!-- Form for editing a product and product locations -->
<form method="POST" enctype="multipart/form-data" id="product-form">
{% csrf_token %}
<div class="form-row">
<div class="form-group col-md-6">
{{ productForm.name.label_tag }} {{ productForm.name }}
</div>
<div class="form-group col-md-6">
{{ productForm.category.label_tag }} {{ productForm.category }}
</div>
</div>
<div class="form-group">
{{ productForm.description.label_tag }} {{ productForm.description }}
{% if productForm.name.errors %}
<ul class="errors">
{% for error in productForm.name.errors %}
<li>{{ error }}</li>
{% endfor %}
</ul>
{% endif %}
</div>
<div class="form-row">
<div class="form-group col-md-6">
{{ productForm.price.label_tag }} {{ productForm.price }}
{% if productForm.price.errors %}
<ul class="errors">
{% for error in productForm.price.errors %}
<li>{{ error }}</li>
{% endfor %}
</ul>
{% endif %}
</div>
<div class="form-group col-md-6">
{{ productForm.selling_price.label_tag }} {{ productForm.selling_price }}
{% if productForm.selling_price.errors %}
<ul class="errors">
{% for error in productForm.selling_price.errors %}
<li>{{ error }}</li>
{% endfor %}
</ul>
{% endif %}
</div>
</div>
<div class="form-group">
{{ productForm.primary_image.label_tag }} {{ productForm.primary_image }}
</div>
<div class="form-group">
{{ productForm.unit_type.label_tag }} {{ productForm.unit_type }}
</div>
<div class="form-group">
<label for="secondary_images">Secondary Images</label>
<input type="file" name="secondary_images" multiple>
</div>
<script>
// JavaScript to enable or disable quantity inputs based on the
// selection of location checkboxes
document.addEventListener('DOMContentLoaded', function() {
const form = document.getElementById('product-form');
const checkboxes = document.querySelectorAll('input[type="checkbox"]
[name="locations"]');
const quantityInputs = document.querySelectorAll('.quantity-input-container
input[type="number"]');
checkbox.addEventListener('change', function() {
quantityInput.disabled = !this.checked;
if (!this.checked) {
quantityInput.value = ''; // Reset quantity input when checkbox is unchecked
}
});
// Initialize the state of the quantity input based on whether the checkbox is
checked
quantityInput.disabled = !checkbox.checked;
});
});
</script>
{% endblock %}
CUSTOMERS.HTML:
{% extends 'admin/base.html' %}
{% block title %}
Customers - Admin Panel
{% endblock %}
{% block breadcrumb %}
<div class="row mb-4 mt-2" style="height: 110px; background: linear-
gradient(90deg, #4B4B4B, #2C3E50);">
<div class="col-lg-8 mt-5">
<h2 style="font-size: 28px;font-weight: 700;color: #ffffff;" class="ml-
5"><b>Customers</b></h2>
</div>
<div class="col-lg-3 mt-4">
<ul class="breadcrumb" style="background-color: #06A245;">
<li class="breadcrumb-item"><a href="{% url 'admin_page'
%}"><b>Admin</b></a></li>
<li style="color: rgb(187, 186, 183);" class="breadcrumb-item
active"><b>Customers</b></li>
</ul>
</div>
</div>
{% endblock %}
{% block content %}
<div class="container">
<table class="table">
<thead style="background-color: #7755A2; color: white;">
<tr>
<th scope="col">Username</th>
<th scope="col">Email</th>
<th scope="col">Status</th>
<th scope="col">Action</th>
</tr>
</thead>
<tbody id="customer-table-body">
{% for customer in customers %}
<tr class="table-success">
<td>{{ customer.username }}</td>
<td>{{ customer.email }}</td>
<td>
{% if customer.is_blocked == False %}
<p>Active</p>
{% else %}
<p>Blocked</p>
{% endif %}
</td>
<td>
<form method="post" action="{% url 'customers' customer.id %}">
{% csrf_token %}
{% if customer.is_blocked == False %}
<button style="background-color: red;" class="btn hvr-hover" type="submit"
name="status" value="blocked">Block</button>
{% else %}
<button class="btn hvr-hover" type="submit" name="status"
value="active">Unblock</button>
{% endif %}
</form>
</td>
</tr>
{% endfor %}
</tbody>
</table>
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<script>
$(document).ready(function(){
const itemsPerPage = 7;
const $customerTableBody = $('#customer-table-body');
const $paginationControls = $('#pagination-controls');
const $customerRows = $customerTableBody.children('tr');
const totalItems = $customerRows.length;
const totalPages = Math.ceil(totalItems / itemsPerPage);
function showPage(page) {
const start = (page - 1) * itemsPerPage;
const end = start + itemsPerPage;
$customerRows.hide();
$customerRows.slice(start, end).show();
$paginationControls.empty();
if (page > 1) {
$paginationControls.append(`<li class="page-item"><a class="page-link"
href="#" data-page="${page - 1}">«</a></li>`);
} else {
$paginationControls.append(`<li class="page-item disabled"><span
class="page-link">«</span></li>`);
}
showPage(1);
});
</script>
{% endblock %}
DASHBOARD.HTML:
{% extends 'admin/base.html' %}
<div class="header">
<h1>Sales Reports - 2024</h1>
</div>
timeframeSelect.addEventListener('change', updateCharts);
function updateCharts() {
const timeframe = timeframeSelect.value;
fetch(`/vgadmin/dashboard/data/?timeframe=${timeframe}`)
.then(response => response.json())
.then(data => {
updateChart(ordersChart, data.orders_data, 'Total Orders');
updateChart(revenueChart, data.revenue_data, 'Total Revenue');
});
}
updateCharts();
});
</script>
{% endblock %}
REPORT.HTML:
{% extends 'admin/base.html' %}
<div class="form-check">
<input type="radio" class="form-check-input" name="report_type"
value="weekly" id="weekly">
<label class="form-check-label" for="weekly">Weekly</label>
</div>
<div class="form-check">
<input type="radio" class="form-check-input" name="report_type"
value="monthly" id="monthly">
<label class="form-check-label" for="monthly">Monthly</label>
</div>
<div class="form-check">
<input type="radio" class="form-check-input" name="report_type"
value="yearly" id="yearly">
<label class="form-check-label" for="yearly">Yearly</label>
</div>
<div class="form-check">
<input type="radio" class="form-check-input" name="report_type"
value="custom" id="custom">
<label class="form-check-label" for="custom">Custom Date Range</label>
</div>
</div>
<script>
document.addEventListener('DOMContentLoaded', function() {
const reportTypeInputs =
document.querySelectorAll('input[name="report_type"]');
const customDateRange = document.getElementById('custom-date-range');
reportTypeInputs.forEach(input => {
input.addEventListener('change', function() {
if (this.value === 'custom') {
customDateRange.style.display = 'block';
} else {
customDateRange.style.display = 'none';
}
});
});
});
</script>
{% endblock %}
ORDERS.HTML:
{% extends 'customer/base.html' %}
{% load static %}
{% block breadcrumb %}
<div class="all-title-box">
<div class="container">
<div class="row">
<div class="col-lg-12">
<h2>My Account</h2>
<ul class="breadcrumb">
<li class="breadcrumb-item"><a href="{% url 'home_page'
%}">Shop</a></li>
<li class="breadcrumb-item"><a href="{% url 'user_profile' %}">My
account</a></li>
<li class="breadcrumb-item active">Order</li>
</ul>
</div>
</div>
</div>
</div>
{% endblock %}
{% block content %}
{% endif %}
</div>
</div>
{% endfor %}
</div>
<nav aria-label="Page navigation example">
<ul class="pagination justify-content-center" id="pagination">
<!-- Pagination items will be added here by JavaScript -->
</ul>
</nav>
</div>
<script>
document.addEventListener('DOMContentLoaded', function() {
const rowsPerPage = 3;
const ordersContainer = document.getElementById('orders-container');
const pagination = document.getElementById('pagination');
const orderItems = ordersContainer.querySelectorAll('.order-item');
const totalPages = Math.ceil(orderItems.length / rowsPerPage);
let currentPage = 1;
function displayOrders(page) {
ordersContainer.innerHTML = '';
const start = (page - 1) * rowsPerPage;
const end = start + rowsPerPage;
const ordersArray = Array.from(orderItems);
const ordersToDisplay = ordersArray.slice(start, end);
ordersToDisplay.forEach(order => ordersContainer.appendChild(order));
}
function updatePagination() {
pagination.innerHTML = '';
for (let i = 1; i <= totalPages; i++) {
const li = document.createElement('li');
li.classList.add('page-item');
if (i === currentPage) li.classList.add('active');
const a = document.createElement('a');
a.classList.add('page-link');
a.style.backgroundColor = '#06A245'; // Change the button color
a.style.color = '#fff'; // Set the text color
a.textContent = i;
a.href = '#';
a.addEventListener('click', (e) => {
e.preventDefault();
currentPage = i;
displayOrders(currentPage);
updatePagination();
});
li.appendChild(a);
pagination.appendChild(li);
}
}
displayOrders(currentPage);
updatePagination();
});
</script>
{% endblock %}
PAYMENT.HTML:
{% extends 'home/index.html' %}
{% block content %}
<div style="align-content: center;">
<form style="margin-left: 45%;" action="{% url 'verify_payment' %}"
method="POST" id="payment-form">
{% csrf_token %}
<input type="hidden" name="razorpay_payment_id"
id="razorpay_payment_id">
<input type="hidden" name="razorpay_order_id" id="razorpay_order_id">
<input type="hidden" name="razorpay_signature" id="razorpay_signature">
<input type="hidden" name="order_id" value="{{ order_id }}">
<button class="hover hvr-hover" id="rzp-button1" type="button">Pay
Now</button>
</form>
</div>
<script src="https://checkout.razorpay.com/v1/checkout.js"></script>
<script>
var options = {
key: "{{ key_id }}", // Your Razorpay key ID
amount: "{{ amount }}", // Amount in paise (make sure it is an integer)
currency: "INR",
name: "VegiGo", // Your business name
description: "Order Payment",
order_id: "{{ order_id }}", // Order ID from backend
handler: function(response) {
// Set the response data to the hidden form inputs
document.getElementById('razorpay_payment_id').value =
response.razorpay_payment_id;
document.getElementById('razorpay_order_id').value =
response.razorpay_order_id;
document.getElementById('razorpay_signature').value =
response.razorpay_signature;
{% extends 'customer/base.html' %}
{% block breadcrumb %}
<div class="all-title-box">
<div class="container">
<div class="row">
<div class="col-lg-12">
<h2>My Account</h2>
<ul class="breadcrumb">
<li class="breadcrumb-item"><a href="{% url 'home_page' %}">Shop</a></li>
<li class="breadcrumb-item"><a href="{% url 'orders_page' %}">Orders</a></li>
<li class="breadcrumb-item active">Order Details</li>
</ul>
</div>
</div>
</div>
</div>
{% endblock %}
{% block content %}
<style>
.gradient-custom {
background: #7755A2;
}
</style>
<h1> Order details</h1>
ADDRESS.HTML:
{% extends 'customer/base.html' %}
{% block title %}
Address
{% endblock %}
{% block breadcrumb %}
<div class="all-title-box">
<div class="container">
<div class="row">
<div class="col-lg-12">
<h2>My Account</h2>
<ul class="breadcrumb">
<li class="breadcrumb-item"><a href="{% url 'home_page' %}">Home</a></li>
<li class="breadcrumb-item active">{% if user.is_authenticated %}
<a href="{% url 'user_profile' %}"> My Account</a>
{% endif %}</li>
<li class="breadcrumb-item active">Address</li>
</ul>
</div>
</div>
</div>
</div>
{% endblock %}
{% block content %}
<div class="card text-center">
<div class="card-body">
<div class="card-header">
Manage Address
</div>
<div class="card-footer text-muted ml-5">
{% if userAddress %}
<div class="alert alert-info" role="alert">
<div id="address-list">
{% for address in addresses %}
<div class="d-flex justify-content-between align-items-center address-row" style="border: 1px solid
#7755A2; text-align: left; margin-top: 5px;">
<div class="col-8">
<div class="col-2 mt-2" style="background-color: #06A245; color: white;">
<b>{{ address.address_type }}</b>
</div>
<p>Name: <b>{{ address.firstname }} {{ address.lastname }}</b> | Phone: <b>{{ address.phone_number
}}</b></p>
<p>Full Address: {{ address.street_address }} </p>
<p>{{ address.city }} {{ address.district }} {{ address.pincode }} ({{ address.landmark }})</p>
</div>
<div>
<!-- Dropdown menu links -->
<a class="btn hvr-hover" href="{% url 'edit_address' address.id %}?return_url=user_address"><i
class="fa-regular fa-pen-to-square"></i></a>
<!-- Button trigger modal -->
<button type="button" style="background-color: red;" class="btn hvr-hover" data-toggle="modal" data-
target="#deleteModal{{ address.id }}">
<i class="fa-solid fa-trash"></i>
</button>
<script>
document.addEventListener('DOMContentLoaded', function() {
const itemsPerPage = 2;
const addressList = document.querySelectorAll('.address-row');
const paginationControls = document.getElementById('pagination-controls');
function showPage(page) {
const start = (page - 1) * itemsPerPage;
const end = start + itemsPerPage;
addressList.forEach((item, index) => {
if (index >= start && index < end) {
item.style.display = 'flex';
} else {
item.style.display = 'none';
}
});
}
if (totalPages > 0) {
paginationControls.firstChild.classList.add('active');
}
}
createPaginationControls(addressList.length, itemsPerPage);
showPage(1);
});
</script>
PROFILE.HTML:
{% extends 'home/index.html' %}
{% load static %}
{% block content %}
</td>
<td >sivasialamadom</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
<div class="service-desc">
<h4>Your Orders</h4>
<p>Track, return, or buy things again</p>
</div>
</div>
</div>
</div>
<div class="col-lg-4 col-md-12">
<div class="account-box">
<div class="service-box">
<div class="service-icon">
{% if user.is_authenticated %}
<a href="{% url 'edit_profile' %}"><i class="fa fa-lock"></i></a>
{% else %}
<a href=""><i class="fa fa-user s_color"></i> My Account</a>
{% endif %}
</div>
<div class="service-desc">
<h4>User profile</h4>
<p>Edit login, name, and gmail</p>
</div>
</div>
</div>
</div>
<div class="col-lg-4 col-md-12">
<div class="account-box">
<div class="service-box">
<div class="service-icon">
{% if user.is_authenticated %}
<a href="{% url 'address_page' %}"> <i class="fa fa-location-arrow"></i></a>
{% endif %}</li>
</div>
<div class="service-desc">
<h4>Your Addresses</h4>
<p>Edit addresses for orders and gifts</p>
</div>
</div>
</div>
</div>
<div class="col-lg-4 col-md-12">
<div class="account-box">
<div class="service-box">
<div class="service-icon">
<a href="{% url 'wallet_page' %}"> <i class="fa fa-credit-card"></i> </a>
</div>
<div class="service-desc">
<h4>Wallet</h4>
<p>See your wallet</p>
</div>
</div>
</div>
</div>
<div class="col-lg-4 col-md-12">
<div class="account-box">
<div class="service-box">
<div class="service-icon">
<a href="{% url 'cart_page' %}"> <i class="fa fa-credit-card"></i> </a>
</div>
<div class="service-desc">
<h4>Cart</h4>
<p>Go to cart</p>
</div>
</div>
</div>
</div>
<div class="col-lg-4 col-md-12">
<div class="account-box">
<div class="service-box">
<div class="service-icon">
<a href="{% url 'wishlist_page' %}"> <i class="fa fa-credit-card"></i> </a>
</div>
<div class="service-desc">
<h4>Wishlist</h4>
<p>See your wishlist</p>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- End My Account -->
{% endblock %}
CART.HTML:
{% extends 'customer/base.html' %}
{% load static %}
{% block breadcrumb %}
<div class="all-title-box">
<div class="container">
<div class="row">
<div class="col-lg-12">
<h2>My Account</h2>
<ul class="breadcrumb">
<li class="breadcrumb-item"><a href="{% url 'shop_page' %}">Shop</a></li>
<li class="breadcrumb-item"><a href="{% url 'user_profile' %}">My Account</a></li>
<li class="breadcrumb-item active">Cart</li>
</ul>
</div>
</div>
</div>
</div>
{% endblock %}
{% block content %}
<div class="cart-box-main">
<div class="container">
{% elif item.max_quantity == 0 %}
<span>Out of Stock</span>
{% endif %}
<span id="quantity-error_{{ item.product.id }}" style="color: red;"></span>
</td>
<td>{{ item.product.unit_type }}</td>
<td class="total-pr">
<p>{{ item.total_price|floatformat:2 }}</p>
</td>
<td class="remove-pr">
<a href="{% url 'remove_cart_item' item.id %}"><i class="fas fa-times"></i></a>
</td>
</tr>
{% endfor %}
{% else %}
<tr>
<td colspan="6">
<h1>There are no cart items</h1>
</td>
</tr>
{% endif %}
</tbody>
</table>
</div>
</div>
{% if cartId %}
<div class="row my-5">
<div class="col-lg-8 col-sm-12"></div>
<div class="col-lg-4 col-sm-12">
<div class="order-box">
<h3>Order summary</h3>
<div class="d-flex">
<h4>Sub Total</h4>
<div class="ml-auto font-weight-bold">{{ total_price|floatformat:2 }} ₹</div>
</div>
<div class="d-flex">
<h4>Discount</h4>
<div class="ml-auto font-weight-bold"> {{ total_discount|floatformat:2 }} ₹</div>
</div>
<hr class="my-1">
<div class="d-flex">
<h4>Delivery Charge</h4>
<div class="ml-auto font-weight-bold"> Free </div>
</div>
<hr>
<div class="d-flex gr-total">
<h5>Grand Total</h5>
<div class="ml-auto h5">{{ cart.sub_total|floatformat:2 }} ₹</div>
</div>
<hr> </div>
</div>
<input type="hidden" name="" id="cart-id-ch" value="{{ cartId }}" disabled>
<div class="col-12 d-flex shopping-box">
<a href="#" id="checkout-btn" class="ml-auto btn hvr-hover">Checkout</a>
</div>
{% endif %}
</div>
</div>
</div>
</div>
<!-- End Cart -->
{% endblock %}
{% block javascript %}
<!-- Add this code inside your HTML file where the checkout button is located -->
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<script>
$(document).ready(function() {
$('#checkout-btn').click(function(event) {
event.preventDefault(); // Prevent the default action of the button
var cartId = $('#cart-id-ch').val(); // Get the cartId from the data attribute of the button
<script>
$(document).ready(function() {
// Handle plus button click
$('.plus-button').on('click', function() {
const input = $(this).prev('input');
const currentQuantity = parseInt(input.val());
const newQuantity = currentQuantity + 1;
const cartId = input.data('cart-id');
const productId = input.attr('name').split('_')[1];
const branchId = $('#branch-select').val(); // Get the selected branch ID
updateCartItem(cartId, productId, newQuantity, input, branchId); // Pass the branch ID to the function
});
if (newQuantity > 0) {
updateCartItem(cartId, productId, newQuantity, input, branchId); // Pass the branch ID to the function
}
});
</script>
<script>
$(document).ready(function() {
// Event listener for branch dropdown change
$('#branch-select').on('change', function() {
// Submit the form when branch selection changes
$('#branch-select-form').submit();
});
});
</script>
{% endblock javascript %}
WISHLIST.HTML:
{% extends 'customer/base.html' %}
{% block breadcrumb %}
<div class="all-title-box">
<div class="container">
<div class="row">
<div class="col-lg-12">
<h2>My Account</h2>
<ul class="breadcrumb">
<li class="breadcrumb-item"><a href="{% url 'home_page' %}">Home</a></li>
<li class="breadcrumb-item"><a href="{% url 'user_profile' %}">My account</a></li>
<li class="breadcrumb-item active">Wishlist</li>
</ul>
</div>
</div>
</div>
</div>
{% endblock %}
{% block content %}
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
<script>
// Check if there's a message passed from the server
var msg = "{{ msg|escapejs }}";
if (msg) {
// Show SweetAlert notification based on the message
Swal.fire({
title: msg,
icon: msg.includes('already exists') ? 'warning' : 'success',
confirmButtonText: 'OK'
});
}
</script>
{% endblock %}