New changes.

main
nataly 1 year ago
parent 657a6641a1
commit 592fb22604

@ -5,7 +5,6 @@ from billing.add import views
urlpatterns = [ urlpatterns = [
path('product', views.add_product, name='addproduct'), path('product', views.add_product, name='addproduct'),
path('service', views.add_service, name='addservice'), path('service', views.add_service, name='addservice'),
path('order', views.add_order, name='addorder'), path('order/<int:customer_id>/', views.add_order, name='addorder'),
path('invoice/<int:order_id>/', views.add_invoice_pdf, name='addinvoice'), path('invoice/<int:order_id>/', views.add_invoice_pdf, name='addinvoice'),
] ]

@ -5,8 +5,8 @@ from django.http import JsonResponse, HttpResponse
from django.template.loader import get_template from django.template.loader import get_template
from django.conf import settings from django.conf import settings
import os import os
from weasyprint import HTML, CSS
from django.core.files.base import ContentFile from django.core.files.base import ContentFile
from weasyprint import HTML, CSS
@ -72,8 +72,10 @@ def add_service (request, *args, **kwargs):
return render(request, 'add_templates/add-service.html', context) return render(request, 'add_templates/add-service.html', context)
def add_order (request, *args, **kwargs): def add_order (request, customer_id):
customers = CustomerProfile.objects.all().order_by('-id') customer= get_object_or_404(CustomerProfile, id=customer_id)
businesses = Business.objects.filter(customer=customer)
if request.method == 'POST': if request.method == 'POST':
customer_id = request.POST.get('customer') customer_id = request.POST.get('customer')
customer = get_object_or_404(CustomerProfile, id=customer_id) customer = get_object_or_404(CustomerProfile, id=customer_id)
@ -104,7 +106,8 @@ def add_order (request, *args, **kwargs):
context = { context = {
'customers': customers, 'customer' : customer,
'businesses' : businesses,
} }
return render(request, 'add_templates/add-order.html', context) return render(request, 'add_templates/add-order.html', context)
@ -176,5 +179,3 @@ def add_invoice_pdf(request, order_id):

@ -11,40 +11,21 @@
<div class="w-full px-5 s:px-9 mb-5"> <div class="w-full px-5 s:px-9 mb-5">
<div class="w-full h-full shadow-md rounded-md py-5 px-3 bg-white"> <div class="w-full h-full shadow-md rounded-md py-5 px-3 bg-white">
<h1 class="text-3xl text-secondosiblue text-center font-semibold"> <h1 class="text-3xl text-secondosiblue text-center font-semibold">
Add Order Add Order for {{customer.user.first_name}} {{customer.user.last_name}}
</h1> </h1>
<form method="POST" action="{% url 'addorder' %}" enctype="multipart/form-data"> <form method="POST" action="{% url 'addorder' customer.id %}" enctype="multipart/form-data">
{% csrf_token %} {% csrf_token %}
<div class="w-full flex flex-col gap-5"> <div class="w-full flex flex-col gap-5">
<div class="w-full">
<label class="text-gray-500">Customer:</label>
<select name="customer" id="customersSelectTag"
class="w-full h-[50px] py-1 px-3 border border-gray-300 outline-none rounded-md text-gray-500 mt-1"
required>
<option selected disabled>Select Customer</option>
{% for customer in customers %}
<option value="{{customer.id}}">{{customer.user.first_name}} {{customer.user.last_name}}
</option>
{% endfor %}
</select>
</div>
<div class="w-full"> <div class="w-full">
<label class="text-gray-500">Business:</label> <label class="text-gray-500">Business:</label>
<select name="business" id="businessSelectTag" <select name="business" id="businessSelectTag"
class="w-full h-[50px] py-1 px-3 border border-gray-300 outline-none rounded-md text-gray-500 mt-1"> class="w-full h-[50px] py-1 px-3 border border-gray-300 outline-none rounded-md text-gray-500 mt-1">
<option selected disabled>Select Customer First</option> <option selected disabled>Businesses</option>
</select> {% for business in businesses %}
</div> <option value="{{business.id}}">{{business.name}}</option>
{% endfor %}
<div class="w-full">
<label class="text-gray-500">Items:</label>
<select name="items" id="itemsSelectTag"
class="border border-gray-300 p-3 rounded-md outline-none w-full text-gray-500 mt-1" multiple
required>
<option selected disabled>Select Customer First</option>
</select> </select>
</div> </div>
@ -69,8 +50,7 @@
</form> </form>
</div> </div>
</div> </div>
<!---------------------- JS SCRIPTS -------------------->
<script src="{% static 'js/billing/add-order.js' %}"></script>

@ -0,0 +1,88 @@
{% extends "main.html" %}
{%load static%}
{% block content %}
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<div class="w-full xxlg1:w-[75%]">
<div class="w-full h-fit bg-white rounded-md shadow-md p-5">
<div class="w-full bg-gray-50 px-3 py-3 border border-gray-100 shadow-md rounded-md flex flex-col s:flex-row justify-between items-start s:items-center gap-3">
<div>
<h1 class="text-secondosiblue text-xl">Order 234443</h1>
<p class="text-gray-500">Salim Elliye</p>
</div>
<p class="uppercase text-green-700 font-semibold">Completed</p>
</div>
<div class="w=full mt-5">
<p class="text-secondosiblue text-xl">Services</p>
<div class="w-full grid grid-cols-1 md:grid-cols-2 l:grid-cols-3 gap-5 mt-3">
<div class="w-full shadow-md">
<div
class="w-ful py-9 px-5 flex justify-center items-center text-center text-secondosiblue bg-gray-100 rounded-t-md">
<p>Service Name</p>
</div>
<div
class="w-ful px-3 py-2 text-white flex justify-center items-center gap-2 bg-osiblue rounded-b-md cursor-pointer">
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5"
stroke="currentColor" class="w-4 h-4 text-white">
<path stroke-linecap="round" stroke-linejoin="round" d="M12 4.5v15m7.5-7.5h-15" />
</svg>
<p>Add</p>
</div>
</div>
</div>
</div>
<div class="w=full mt-10">
<p class="text-secondosiblue text-xl">Products</p>
<div class="w-full grid grid-cols-1 md:grid-cols-2 l:grid-cols-3 gap-5 mt-5">
<div>
<div class="w-full p-9 border border-gray-200 flex flex-col items-center gap-5 rounded-t-md bg-white">
<p class="text-secondosiblue uppercase font-poppinsBold text-xl text-center">Basic
</p>
<div class="w-full flex flex-col justify-center items-center text-center">
<p class="text-osiblue font-poppinsLight text-[17px] font-semibold">$0</p>
<p class="text-gray-500">monthly/restaurant</p>
</div>
</div>
<div
class="w-ful px-3 py-2 text-white flex justify-center items-center gap-2 bg-osiblue border border-osiblue rounded-b-md cursor-pointer">
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5"
stroke="currentColor" class="w-4 h-4 text-white">
<path stroke-linecap="round" stroke-linejoin="round" d="M12 4.5v15m7.5-7.5h-15" />
</svg>
<p>Add</p>
</div>
</div>
<div>
<div class="w-full p-9 border border-gray-200 flex flex-col items-center gap-5 rounded-t-md bg-white">
<p class="text-secondosiblue uppercase font-poppinsBold text-xl text-center">Standard
</p>
<div class="w-full flex flex-col justify-center items-center text-center">
<p class="text-osiblue font-poppinsLight text-[17px] font-semibold">$20</p>
<p class="text-gray-500">monthly/restaurant</p>
</div>
</div>
<div
class="w-ful px-3 py-2 text-white flex justify-center items-center gap-2 bg-osiblue border border-osiblue rounded-b-md cursor-pointer">
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5"
stroke="currentColor" class="w-4 h-4 text-white">
<path stroke-linecap="round" stroke-linejoin="round" d="M12 4.5v15m7.5-7.5h-15" />
</svg>
<p>Add</p>
</div>
</div>
</div>
</div>
</div>
</div>
{% endblock %}

@ -18,13 +18,6 @@
</button> </button>
</div> </div>
</div> </div>
<div class="w-full s:w-fit">
<a href="{% url 'addorder' %}">
<button
class="w-full s:w-fit text-base px-3 py-2 bg-osiblue text-white outline-none border border-osiblue rounded-md cursor-pointer hover:bg-white hover:text-osiblue duration-300">Add
Order</button>
</a>
</div>
</div> </div>
<div class="overflow-x-auto border border-gray-300 rounded-md mt-4"> <div class="overflow-x-auto border border-gray-300 rounded-md mt-4">
@ -78,7 +71,7 @@
<td class="px-6 py-4"> <td class="px-6 py-4">
<div class="w-full flex justify-center items-center gap-3"> <div class="w-full flex justify-center items-center gap-3">
<a href=""> <a href="{% url 'orderdetails' order.id %}">
<div class="text-[15px] text-blue-500 cursor-pointer"> <div class="text-[15px] text-blue-500 cursor-pointer">
<i class="fa fa-eye"></i> <i class="fa fa-eye"></i>
</div> </div>

@ -13,7 +13,5 @@ urlpatterns = [
# DETAILS # DETAILS
path('invoice-details/<int:order_id>/', views.invoice_details, name='invoicedetails'), path('invoice-details/<int:order_id>/', views.invoice_details, name='invoicedetails'),
path('order-details/<int:order_id>/', views.order_details, name='orderdetails'),
path('fetch-customer-items/<int:customer_id>/', views.fetch_customer_items, name='fetch_customer_items'),
path('fetch-customer-businesses/<int:customer_id>/', views.fetch_customer_businesses, name='fetch_customer_businesses'),
] ]

@ -47,42 +47,15 @@ def invoice_details(request, order_id):
return render(request, 'details_templates/invoice-details.html', context) return render(request, 'details_templates/invoice-details.html', context)
def order_details(request, order_id):
order = get_object_or_404(Order, id=order_id)
context = {
'order' : order,
# TO FETCH THE ITEMS RELATED TO TH SELECTED CUSTOMER AND THE ITEMS THAT ARE NOT RELATED TO A CUSTOMER
def fetch_customer_items(request, customer_id):
customer = get_object_or_404(CustomerProfile, id=customer_id)
items_related_to_customer = Item.objects.filter(customer=customer)
items_without_customer = Item.objects.filter(customer__isnull=True)
data = {
'items_related_to_customer': list(items_related_to_customer.values('id', 'title')),
'items_without_customer': list(items_without_customer.values('id', 'title')),
} }
return JsonResponse(data) return render(request, 'details_templates/order-details.html', context)
def fetch_customer_businesses(request, customer_id):
try:
customer_profile = CustomerProfile.objects.get(id=customer_id)
except CustomerProfile.DoesNotExist:
customer_profile = None
if customer_profile:
businesses = Business.objects.filter(customer=customer_profile)
# Create a list to hold dictionary representations of each business
business_data = []
for business in businesses:
business_data.append({
'id': business.id,
'name': business.name,
})
else:
business_data = None
return JsonResponse({'businesses': business_data})

@ -20,17 +20,30 @@
<div class="w-full"> <div class="w-full">
<label class="text-gray-500">What is this regarding?</label> <label class="text-gray-500">What is this regarding?</label>
<select class="w-full h-[50px] py-1 px-3 border border-gray-300 outline-none rounded-md mt-1"> <select class="w-full h-[50px] py-1 px-3 border border-gray-300 outline-none rounded-md mt-1" id="regardingSelectTag">
<option value="General/Account/Billing">General/Account/Billing</option> <option value="General/Account/Billing">General/Account/Billing</option>
{% for customer_product in customer_products %} <option value="Product">Product</option>
<option value="">{{customer_product.item.title}}</option> <option value="Project">Project</option>
{% endfor %}
{% for customer_project in customer_projects %}
<option value="">{{customer_project.title}}</option>
{% endfor %}
</select> </select>
</div> </div>
<!-- Projects Select Tag -->
<select class="w-full h-[50px] py-1 px-3 border border-gray-300 outline-none rounded-md hidden" id="projectsSelectTag">
<option selected disabled>Choose one of your projects</option>
{% for customer_project in customer_projects %}
<option value="">{{customer_project.title}}</option>
{% endfor %}
</select>
<!-- Products Select Tag -->
<select class="w-full h-[50px] py-1 px-3 border border-gray-300 outline-none rounded-md hidden" id="productsSelectTag">
<option selected disabled>Choose one of your products</option>
{% for customer_product in customer_products %}
<option value="">{{customer_product.item.title}}</option>
{% endfor %}
</select>
<div class="w-full"> <div class="w-full">
<label class="text-gray-500">Description:</label> <label class="text-gray-500">Description:</label>
<textarea required name="description" <textarea required name="description"
@ -64,4 +77,8 @@
<!-------------- JS SCRIPTS ---------------> <!-------------- JS SCRIPTS --------------->
<script type="text/javascript" src='{% static "js/upload-input-tag.js" %}'></script> <script type="text/javascript" src='{% static "js/upload-input-tag.js" %}'></script>
<!-- TO DISPLAY THE CHOSEN REGARDING OPTION SELECT TAG -->
<script type="text/javascript" src='{% static "js/customer_dashboard/regarding-ticket.js" %}'></script>
{% endblock %} {% endblock %}

Binary file not shown.

@ -26,6 +26,12 @@
} }
/* SCROLL BAR OF NOTIFICATIONS CONTAINER IN NOTIFICATIONS SIDE BAR */
.notificationsContainer::-webkit-scrollbar {
width: 0px;
}
/* Website's font */ /* Website's font */
@font-face { @font-face {

@ -27,7 +27,7 @@ urlpatterns = [
path('reference/', views.add_reference_modal, name='addreferencemodal'), path('reference/', views.add_reference_modal, name='addreferencemodal'),
path('tag/', views.add_tag_modal, name='addtagmodal'), path('tag/', views.add_tag_modal, name='addtagmodal'),
path('reaction/<int:status_id>/<str:emoji>/', views.add_reaction, name='add_reaction'), path('reaction/<int:status_id>/<str:emoji>/', views.add_reaction, name='add_reaction'),
path('add-ticket/', views.add_ticket, name='addticket'), path('add-ticket/<int:customer_id>/', views.add_ticket, name='addticket'),
] ]

@ -7,6 +7,8 @@ from django.http import HttpResponseRedirect
from datetime import date from datetime import date
from django.http import JsonResponse from django.http import JsonResponse
from osinacore.decorators import * from osinacore.decorators import *
from billing.models import *
@staff_login_required @staff_login_required
@ -597,10 +599,14 @@ def add_reaction(request, status_id, emoji):
@staff_login_required @staff_login_required
def add_ticket(request, *args, **kwargs): def add_ticket(request, customer_id):
customer= get_object_or_404(CustomerProfile, id=customer_id)
context = { customer_products = OrderItem.objects.filter(order__status='Completed', active__in=[True, None], item__type='Product', order__customer=customer).values()
customer_projects = Project.objects.filter(customer=customer)
context = {
'customer_products' : customer_products,
'customer_projects' : customer_projects,
} }
return render(request, 'add_templates/add-ticket.html', context) return render(request, 'add_templates/add-ticket.html', context)

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save