added the print pdf for the po
This commit is contained in:
parent
38add18a17
commit
52200b2639
@ -10987,14 +10987,32 @@ class PurchaseOrderDetailView(LoginRequiredMixin, PermissionRequiredMixin, Detai
|
||||
def get(self, request, *args, **kwargs):
|
||||
self.object = self.get_object()
|
||||
context = self.get_context_data(object=self.object)
|
||||
po_items_qs, item_data = self.object.get_itemtxs_data(
|
||||
queryset=self.object.itemtransactionmodel_set.all().select_related(
|
||||
"item_model", "bill_model"
|
||||
)
|
||||
)
|
||||
|
||||
if self.object.po_status == 'fulfilled':
|
||||
context['po_items_list']=po_items_qs
|
||||
context['vendor']=po_items_qs.first().bill_model.vendor
|
||||
context['dealer']=request.dealer
|
||||
|
||||
# Check if PDF format is requested
|
||||
if request.GET.get('format') == 'pdf':
|
||||
# Use a separate, print-friendly template for the PDF
|
||||
if request.GET.get('lang')=='en':
|
||||
html_string = render_to_string(
|
||||
"purchase_orders/po_detail_pdf.html",
|
||||
"purchase_orders/po_detail_en_pdf.html",
|
||||
context
|
||||
)
|
||||
else:
|
||||
html_string=render_to_string(
|
||||
"purchase_orders/po_detail_ar_pdf.html",
|
||||
context
|
||||
)
|
||||
|
||||
|
||||
|
||||
# Use WeasyPrint to generate the PDF
|
||||
pdf = HTML(string=html_string).write_pdf()
|
||||
|
||||
@ -76,25 +76,22 @@
|
||||
{% endif %}
|
||||
<!-- Main row -->
|
||||
{% if car.ready %}
|
||||
<div class="d-flex align-items-center">
|
||||
<div class="d-flex align-items-center gap-2 mb-2">
|
||||
<button type="button"
|
||||
class="btn btn-sm btn-phoenix-success mb-2 me-2"
|
||||
class="btn btn-sm btn-phoenix-success"
|
||||
data-bs-toggle="modal"
|
||||
data-bs-target="#estimateModal">
|
||||
{% trans 'Create Estimate' %}
|
||||
</button>
|
||||
<div class="d-flex align-items-center">
|
||||
<span class="badge rounded-10 badge-phoenix-success">{{active_estimates|length}}</span>
|
||||
<div class="d-flex flex-wrap gap-2 ms-2">
|
||||
{% for e in active_estimates %}
|
||||
<div class="d-flex flex-column gap-2">
|
||||
<span class="badge rounded-10 badge-phoenix-success">{{e.content_object.estimate_number}}</span>
|
||||
<span class="badge rounded-10 badge-phoenix-success">{{e.related_object}}</span>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% if active_estimates %}
|
||||
<button type="button" class="btn btn-phoenix-warning btn-sm"
|
||||
data-bs-toggle="modal"
|
||||
data-bs-target="#activeEstimatesModal">
|
||||
{% trans "Active Estimates" %}
|
||||
<span class="ms-2 badge rounded-pill text-bg-light">{{ active_estimates|length }}</span>
|
||||
</button>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endif %}
|
||||
{% if perms.inventory.view_car %}
|
||||
<div class="row-fluid {% if car.status == 'sold' %}disabled{% endif %}">
|
||||
@ -638,6 +635,32 @@
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
<!--active estimate modal-->
|
||||
|
||||
<div class="modal fade" id="activeEstimatesModal" tabindex="-1" aria-labelledby="activeEstimatesModalLabel" aria-hidden="true">
|
||||
<div class="modal-dialog modal-dialog-top">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title" id="activeEstimatesModalLabel">Active Estimates ({{ active_estimates|length }})</h5>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<div class="d-flex flex-column gap-3">
|
||||
{% for e in active_estimates %}
|
||||
<div class="d-flex align-items-center gap-2 border-bottom pb-2">
|
||||
<span class="badge rounded-pill bg-primary text-light me-1">{{ e.content_object.estimate_number }}</span class="text-nowrap"><span>{% trans " created by: " %}</span>
|
||||
<div class="text-muted">{{ e.related_object }}</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-phoenix-secondary" data-bs-dismiss="modal">{% trans "Close" %}</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
{% block customJS %}
|
||||
<script>
|
||||
|
||||
@ -8,6 +8,7 @@
|
||||
{% trans "Purchase Order Detail" %}
|
||||
{% endblock %}
|
||||
{% block content %}
|
||||
|
||||
<div class="container-fluid mt-4">
|
||||
<div class="row g-1">
|
||||
<div class="col-lg-12 mb-3">
|
||||
@ -15,10 +16,14 @@
|
||||
<div class="card-body">
|
||||
{% include 'purchase_orders/includes/card_po.html' with dealer_slug=request.dealer.slug po_model=po_model entity_slug=entity_slug style='po-detail' %}
|
||||
</div>
|
||||
<div>
|
||||
<a class="btn btn-phoenix-primary w-100 my-2"
|
||||
href="{{ request.path }}?format=pdf"><i class="fa-solid fa-arrow-down me-1"></i>{% trans 'Download PDF' %}</a>
|
||||
</di>
|
||||
{% if po_model.po_status == 'fulfilled' %}
|
||||
<div class="ms-2">
|
||||
<a class="btn btn-phoenix-primary my-2 mx-2"
|
||||
href="{{ request.path }}?format=pdf&lang=en"><i class="fa-solid fa-arrow-down me-1"></i>{% trans 'Download PO ENG' %}</a>
|
||||
<a class="btn btn-phoenix-primary my-2"
|
||||
href="{{ request.path }}?format=pdf&lang=ar"><i class="fa-solid fa-arrow-down me-1"></i>{% trans 'Download PO ARB' %}</a>
|
||||
</diV>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-lg-12">
|
||||
|
||||
182
templates/purchase_orders/po_detail_ar_pdf.html
Normal file
182
templates/purchase_orders/po_detail_ar_pdf.html
Normal file
@ -0,0 +1,182 @@
|
||||
{% load i18n %}
|
||||
{% load static %}
|
||||
{% load django_ledger %}
|
||||
{% load tenhal_tag %}
|
||||
{% load custom_filters %}
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html lang="ar" dir="rtl">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>{{ po_model.po_number }}</title>
|
||||
<style>
|
||||
@font-face {
|
||||
font-family: 'Noto Sans Arabic';
|
||||
src: url('https://fonts.gstatic.com/s/notosansarabic/v35/or3qQxoQpw-Gv0yqj6V1p-B3.ttf') format('truetype');
|
||||
}
|
||||
|
||||
/* General Body and Font Styles */
|
||||
body {
|
||||
font-family: 'Noto Sans Arabic', sans-serif;
|
||||
font-size: 12px;
|
||||
color: #333;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
direction: rtl; /* This is the key for RTL support */
|
||||
}
|
||||
|
||||
/* Page Layout and Margins for PDF */
|
||||
@page {
|
||||
size: A4;
|
||||
margin: 20mm;
|
||||
@top-left {
|
||||
content: "صفحة " counter(page) " من " counter(pages);
|
||||
font-size: 10px;
|
||||
color: #555;
|
||||
}
|
||||
}
|
||||
|
||||
/* Header Styles */
|
||||
.document-header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
border-bottom: 2px solid #333;
|
||||
padding-bottom: 15px;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
.document-header .logo {
|
||||
max-width: 150px;
|
||||
height: auto;
|
||||
}
|
||||
.document-header h1 {
|
||||
font-size: 24px;
|
||||
margin: 0;
|
||||
color: #0056b3; /* A professional blue */
|
||||
}
|
||||
.document-header address {
|
||||
text-align: left; /* Aligned to the left for RTL layout */
|
||||
font-style: normal;
|
||||
font-size: 10px;
|
||||
}
|
||||
|
||||
/* Document Details Section */
|
||||
.document-details {
|
||||
display: flex;
|
||||
flex-direction: row-reverse; /* Reverses the order of the sections */
|
||||
justify-content: space-between;
|
||||
margin-bottom: 30px;
|
||||
line-height: 1.6;
|
||||
}
|
||||
.document-details .section {
|
||||
width: 48%;
|
||||
}
|
||||
.document-details h2 {
|
||||
font-size: 14px;
|
||||
border-bottom: 1px solid #ccc;
|
||||
padding-bottom: 5px;
|
||||
margin-bottom: 10px;
|
||||
color: #555;
|
||||
}
|
||||
.document-details p {
|
||||
margin: 0;
|
||||
font-size: 12px;
|
||||
}
|
||||
.document-details .label {
|
||||
font-weight: bold;
|
||||
color: #555;
|
||||
}
|
||||
|
||||
/* Table Styles */
|
||||
.table {
|
||||
width: 100%;
|
||||
border-collapse: collapse;
|
||||
margin-top: 20px;
|
||||
}
|
||||
.table th, .table td {
|
||||
border: 1px solid #ddd;
|
||||
padding: 8px;
|
||||
text-align: right; /* Aligned to the right for RTL layout */
|
||||
}
|
||||
.table th {
|
||||
background-color: #f2f2f2;
|
||||
font-weight: bold;
|
||||
}
|
||||
.table tfoot td {
|
||||
border-top: 2px solid #333;
|
||||
font-weight: bold;
|
||||
}
|
||||
.text-right {
|
||||
text-align: left; /* This is now for left alignment in an RTL context */
|
||||
}
|
||||
|
||||
/* Footer Styles */
|
||||
.document-footer {
|
||||
text-align: center;
|
||||
font-size: 10px;
|
||||
color: #888;
|
||||
border-top: 1px solid #ddd;
|
||||
padding-top: 15px;
|
||||
margin-top: 30px;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="document-header">
|
||||
<div>
|
||||
<h1>أمر شراء</h1>
|
||||
<h2 style="font-size: 18px;">{{ po_model.po_number }}</h2>
|
||||
</div>
|
||||
<div>
|
||||
{% if dealer.logo %}
|
||||
<img src="{{ dealer.logo.url }}" alt="شعار الشركة" class="logo">
|
||||
{% else %}
|
||||
<h1>{{ dealer.name }}</h1>
|
||||
{% endif %}
|
||||
<address>
|
||||
العنوان: {{ dealer.address }}<br>
|
||||
البريد الإلكتروني: {{ dealer.user.email }}<br>
|
||||
الهاتف: {{ dealer.phone_number }}<br>
|
||||
رقم السجل التجاري: {{ dealer.crn }} | رقم ضريبة القيمة المضافة: {{ dealer.vrn }}
|
||||
</address>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="document-details">
|
||||
<div class="section">
|
||||
<h2>التفاصيل:</h2>
|
||||
<p><span class="label">رقم أمر الشراء:</span> {{ po_model.po_number }}</p>
|
||||
<p><span class="label">تاريخ الإصدار:</span> {{ po_model.date_fulfilled|date:"Y/m/d" }}</p>
|
||||
</div>
|
||||
<div class="section">
|
||||
<h2>يُرسل إلى:</h2>
|
||||
<p><span class="label">المورد:</span> {{ vendor.vendor_name }}</p>
|
||||
<p><span class="label">البريد الإلكتروني:</span> {{ vendor.email }}</p>
|
||||
<p><span class="label">الهاتف:</span> {{ vendor.phone }}</p>
|
||||
<p><span class="label">العنوان:</span> {{ vendor.address_1 }}</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-lg-12">
|
||||
<div class="table-responsive">
|
||||
{% include 'purchase_orders/tags/po_item_table_print_ar.html' with po_items_list=po_items_list %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="document-details" style="margin-top: 30px;">
|
||||
<div class="section" style="width: 100%;">
|
||||
<h2>ملاحظات:</h2>
|
||||
<p>{{ po_model.notes|default:"لا توجد ملاحظات إضافية." }}</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="document-details" style="margin-top: 10px; border-top: 1px solid #ddd; padding-top: 10px;">
|
||||
<div class="section text-right" style="width: 100%;">
|
||||
<p class="h4"><span class="label">المبلغ الإجمالي:</span> {{ po_total_amount|floatformat:'2g' }}<span class="icon-saudi_riyal"></span></p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="document-footer">
|
||||
<p>© حائل {% now "Y" %} جميع الحقوق محفوظة.</p>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@ -115,19 +115,18 @@
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div class="document-header">
|
||||
<div>
|
||||
{% if request.dealer.logo %}
|
||||
<img src="{{ request.dealer.logo.url }}" alt="Company Logo" class="logo">
|
||||
<img src="{{ dealer.logo.url }}" alt="Company Logo" class="logo">
|
||||
{% else %}
|
||||
<h1>{{ request.dealer.name }}</h1>
|
||||
<h1>{{ dealer.name }}</h1>
|
||||
{% endif %}
|
||||
<address>
|
||||
{{ request.dealer.entity.address.street }}<br>
|
||||
{{ request.dealer.entity.address.city }}, {{ request.dealer.entity.address.state }} {{ request.dealer.entity.address.zip_code }}<br>
|
||||
Email: {{ request.dealer.user.email }}<br>
|
||||
Phone: {{ request.dealer.phone }}
|
||||
Address: {{ dealer.address}}<br>
|
||||
Email: {{ dealer.user.email }}<br>
|
||||
Phone: {{dealer.phone_number }}<br>
|
||||
CRN: {{dealer.crn}} | VRN: {{dealer.vrn}}
|
||||
</address>
|
||||
</div>
|
||||
<div>
|
||||
@ -139,39 +138,32 @@
|
||||
<div class="document-details">
|
||||
<div class="section">
|
||||
<h2>BILL TO:</h2>
|
||||
<p><span class="label">Vendor:</span> </p>
|
||||
<p><span class="label">Email:</span> </p>
|
||||
<p><span class="label">Phone:</span> </p>
|
||||
<p><span class="label">Address:</span> </p>
|
||||
<p>{{ po_model.vendor_model.address.city|default:"" }}, {{ po_model.vendor_model.address.state|default:"" }} {{ po_model.vendor_model.address.zip_code|default:"" }}</p>
|
||||
<p><span class="label">Vendor: {{vendor.vendor_name}}</span> </p>
|
||||
<p><span class="label">Email: {{vendor.email}}</span> </p>
|
||||
<p><span class="label">Phone: {{vendor.phone}}</span> </p>
|
||||
<p><span class="label">Address: {{vendor.address_1}}</span> </p>
|
||||
</div>
|
||||
<div class="section">
|
||||
<h2>DETAILS:</h2>
|
||||
<p><span class="label">PO Number:</span> {{ po_model.po_number }}</p>
|
||||
<p><span class="label">Issue Date:</span> {{ po_model.date_created|date:"F j, Y" }}</p>
|
||||
<p><span class="label">Status:</span> {{ po_model.get_po_status_display }}</p>
|
||||
<p><span class="label">Due Date:</span> {{ po_model.due_date|date:"F j, Y"|default:"N/A" }}</p>
|
||||
<p><span class="label">Issue Date:</span> {{ po_model.date_fulfilled|date:"F j, Y" }}</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-lg-12">
|
||||
<div class="table-responsive">
|
||||
{% po_item_table1 po_items %}
|
||||
{% include 'purchase_orders/tags/po_item_table_print_en.html' with po_items_list=po_items_list %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="document-details" style="margin-top: 30px;">
|
||||
<div class="section">
|
||||
<h2>NOTES:</h2>
|
||||
<p>{{ po_model.notes|default:"No additional notes." }}</p>
|
||||
</div>
|
||||
|
||||
<div class="section text-right">
|
||||
<p class="h4"><span class="label">Total Amount:</span> {{ po_total_amount|currency_format }}<span class="icon-saudi_riyal"></span></p>
|
||||
<p class="h4"><span class="label">Total Amount:</span> {{ po_total_amount|floatformat:'2g' }}<span class="icon-saudi_riyal"></span></p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="document-footer">
|
||||
<p>© {% now "Y" %} {{ request.dealer.name }}. All rights reserved.</p>
|
||||
<p>© Haikal {% now "Y" %} {{ request.dealer.name }}. All rights reserved.</p>
|
||||
</div>
|
||||
|
||||
</body>
|
||||
39
templates/purchase_orders/tags/po_item_table_print_ar.html
Normal file
39
templates/purchase_orders/tags/po_item_table_print_ar.html
Normal file
@ -0,0 +1,39 @@
|
||||
{% load tenhal_tag %}
|
||||
{% load custom_filters%}
|
||||
<div class="table-container" dir="rtl">
|
||||
<table class="table is-fullwidth is-striped is-narrow is-bordered">
|
||||
<thead>
|
||||
<tr class="has-text-centered bg-body-highlight">
|
||||
<th>البند</th>
|
||||
<th>سعر الوحدة</th>
|
||||
<th>كمية أمر الشراء</th>
|
||||
<th>المبلغ</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for item in po_items_list %}
|
||||
<tr>
|
||||
<td>{{ item.item_model }}</td>
|
||||
<td class="has-text-centered">{{ item.po_unit_cost }}</td>
|
||||
<td class="has-text-centered">{{ item.po_quantity }}</td>
|
||||
<td class="has-text-centered">
|
||||
<span class="icon-saudi_riyal"></span>{{ item.po_total_amount | currency_format }}
|
||||
</td>
|
||||
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
<tfoot>
|
||||
<tr>
|
||||
|
||||
<td></td>
|
||||
<td class="has-text-left">إجمالي مبلغ أمر الشراء</td>
|
||||
<td class="has-text-weight-bold has-text-centered">
|
||||
<span class="icon-saudi_riyal"></span>{{ po_model.po_amount | currency_format }}
|
||||
</td>
|
||||
<td></td>
|
||||
|
||||
</tr>
|
||||
</tfoot>
|
||||
</table>
|
||||
</div>
|
||||
39
templates/purchase_orders/tags/po_item_table_print_en.html
Normal file
39
templates/purchase_orders/tags/po_item_table_print_en.html
Normal file
@ -0,0 +1,39 @@
|
||||
{%load tenhal_tag%}
|
||||
{% load custom_filters%}
|
||||
<div class="table-container">
|
||||
<table class="table is-fullwidth is-striped is-narrow is-bordered">
|
||||
<thead>
|
||||
<tr class="has-text-centered bg-body-highlight">
|
||||
<th>Item</th>
|
||||
<th>Unit Cost</th>
|
||||
<th>PO Qty</th>
|
||||
<th>Amount</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for item in po_items_list %}
|
||||
<tr>
|
||||
<td>{{ item.item_model }}</td>
|
||||
<td class="has-text-centered">{{ item.po_unit_cost }}</td>
|
||||
<td class="has-text-centered">{{ item.po_quantity }}</td>
|
||||
<td class="has-text-centered">
|
||||
<span class="icon-saudi_riyal"></span>{{ item.po_total_amount | currency_format }}
|
||||
</td>
|
||||
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
<tfoot>
|
||||
<tr>
|
||||
|
||||
<td></td>
|
||||
<td class="has-text-right">Total PO Amount</td>
|
||||
<td class="has-text-weight-bold has-text-centered">
|
||||
<span class="icon-saudi_riyal"></span>{{ po_model.po_amount | currency_format }}
|
||||
</td>
|
||||
<td></td>
|
||||
|
||||
</tr>
|
||||
</tfoot>
|
||||
</table>
|
||||
</div>
|
||||
Loading…
x
Reference in New Issue
Block a user