cmc-sales/cmc-django/cmcsales/cmc/templates/enquiry_detail.html

389 lines
15 KiB
HTML
Raw Normal View History

{% extends "cmc/base.html" %} {# Or your actual base template path #}
{% load static %}
{% block title %}{{ page_title }}{% endblock %}
{% block content %}
<div class="enquiries-view">
<dl class="enquirySummary">
<dt>{% translate "Enquiry" %}:</dt>
<dd>{{ enquiry.title }}</dd>
<dt>{% translate "Customer" %}:</dt>
<dd>
{% if enquiry.customer %}
<a href="{% url 'customer_detail' enquiry.customer.id %}">{{ enquiry.customer.name }}</a>
{% else %}
N/A
{% endif %}
</dd>
<dt>{% translate "Contact" %}:</dt>
<dd>
{% if enquiry.contact %}
<a href="{% url 'contact_detail' enquiry.contact.id %}">{{ enquiry.contact.first_name }} {{ enquiry.contact.last_name }}</a>
<a href="mailto:{{ enquiry.contact.email }}">{{ enquiry.contact.email }}</a>
{% else %}
N/A
{% endif %}
</dd>
{% comment %} Status CSS Class Logic {% endcomment %}
{% with status_id=enquiry.status.id|default:0 %}
{% if status_id == 3 %}{%_status_class = "jobwon" %}{% endif %}
{% if status_id == 4 or status_id == 8 or status_id == 9 or status_id == 10 %}{%_status_class = "joblost" %}{% endif %}
{% if status_id == 6 %}{%_status_class = "information" %}{% endif %}
{% if status_id == 11 %}{%_status_class = "informationsent" %}{% endif %}
{% if status_id == 5 %}{%_status_class = "quoted" %}{% endif %}
{% if status_id == 1 %}{%_status_class = "requestforquote" %}{% endif %}
{% endwith %}
<dt>{% translate "Status" %}:</dt>
<dd {% if _status_class %}class="{{ _status_class }}"{% endif %}>
{% if enquiry.status %}
<a href="{% url 'status_detail' enquiry.status.id %}">{{ enquiry.status.name }}</a>
{% else %}
N/A
{% endif %}
</dd>
</dl>
<h3>{% translate "Details" %}</h3>
<dl>
<dt>{% translate "Assigned to User" %}</dt>
<dd>
{% if enquiry.user %}
<a href="{% url 'user_detail' enquiry.user.id %}">{{ enquiry.user.username }}</a>
{% else %}
N/A
{% endif %}
</dd>
<dt>{% translate "State" %}</dt>
<dd>
{% if enquiry.state %}
<a href="{% url 'state_detail' enquiry.state.id %}">{{ enquiry.state.name }}</a>
{% else %}
N/A
{% endif %}
</dd>
<dt>{% translate "Country" %}</dt>
<dd>
{% if enquiry.country %}
<a href="{% url 'country_detail' enquiry.country.id %}">{{ enquiry.country.name }}</a>
{% else %}
N/A
{% endif %}
</dd>
<dt>{% translate "GST Applicable" %}</dt>
<dd>
{% if enquiry.gst %}
{% translate "Yes - GST Applicable" %}
{% else %}
{% translate "No - GST Not Applicable" %}
{% endif %}
</dd>
<dt>{% translate "Principle" %}</dt>
<dd>
{% if enquiry.principle %}
<a href="{% url 'principle_detail' enquiry.principle.id %}">{{ enquiry.principle.name }}</a>
{% else %}
N/A
{% endif %}
</dd>
<dt>{% translate "Comments" %}</dt>
<dd>
<span class="enquiry-view-comments">
{{ enquiry.comments|linebreaksbr|default_if_none:"" }}
</span>
</dd>
<dt>{% translate "Billing Address" %}</dt>
<dd>
{% if enquiry.billing_address %}
{{ enquiry.billing_address.address_line_1 }}<br>
{% if enquiry.billing_address.address_line_2 %}{{ enquiry.billing_address.address_line_2 }}<br>{% endif %}
{{ enquiry.billing_address.city }} {{ enquiry.billing_address.state.name }} {{ enquiry.billing_address.postcode }}<br>
<b>{{ enquiry.billing_address.country.name }}</b>
{% else %}
{% translate "No Billing Address Assigned for this Enquiry" %}
{% endif %}
</dd>
<dt>{% translate "Shipping Address" %}</dt>
<dd>
{% if enquiry.shipping_address %}
{{ enquiry.shipping_address.address_line_1 }}<br>
{% if enquiry.shipping_address.address_line_2 %}{{ enquiry.shipping_address.address_line_2 }}<br>{% endif %}
{{ enquiry.shipping_address.city }} {{ enquiry.shipping_address.state.name }} {{ enquiry.shipping_address.postcode }}<br>
<b>{{ enquiry.shipping_address.country.name }}</b>
{% else %}
{% translate "No Shipping Address Assigned for this Enquiry" %}
{% endif %}
</dd>
</dl>
<div class="enquiry-actions">
<ul>
<li><a href="{% url 'enquiry_edit' enquiry.id %}">{% translate "Edit Enquiry" %}</a></li>
</ul>
</div>
</div>
<div class="principle-emails">
{% comment %}
Convert 'principle_contacts_email_box' element.
This will likely be an include tag.
You'll need to create 'cmc/partials/principle_contacts_email_box.html'
and pass the necessary context.
{% endcomment %}
{% if principle_contacts %}
{% include 'cmc/partials/principle_contacts_email_box.html' with enquiry_title=enquiry.title principle_contacts=principle_contacts %}
{% endif %}
</div>
<div class="related">
<h3>
{{ enquiry.quotes.count }} {% if enquiry.quotes.count == 1 %}{% translate "Quote" %}{% else %}{% translate "Quotes" %}{% endif %}
</h3>
{% if quotes %}
{% include 'cmc/partials/quote_table.html' with quotes=quotes %}
{% else %}
<p>{% translate "No quotes for this enquiry." %}</p>
{% endif %}
</div>
<div class="related">
<h3>{% translate "Jobs from this Enquiry" %}</h3>
{% if jobs %}
<table cellpadding="0" cellspacing="0">
<thead>
<tr>
<th>{% translate "Job Number" %}</th>
<th>{% translate "Customer Order Number" %}</th>
<th>{% translate "Date Order Received" %}</th>
<th>{% translate "Date Scheduled Ex-Works" %}</th>
<th>{% translate "Date Sent to Customer" %}</th>
<th>{% translate "Domestic Freight Paid By" %}</th>
<th class="actions">{% translate "Actions" %}</th>
</tr>
</thead>
<tbody>
{% for job in jobs %}
<tr class="{% if forloop.counter|divisibleby:2 %}altrow{% endif %}">
<td>{{ job.title|default_if_none:"" }}</td>
<td>{{ job.customer_order_number|default_if_none:"" }}</td>
<td>{{ job.date_order_received|date:"j M Y"|default_if_none:"" }}</td>
<td>{{ job.date_scheduled_ex_works|date:"j M Y"|default_if_none:"" }}</td>
<td>{{ job.date_order_sent_to_customer|date:"j M Y"|default_if_none:"" }}</td>
<td>{{ job.domestic_freight_paid_by|default_if_none:"" }}</td>
<td class="actions">
<a href="{% url 'job_detail' job.id %}">{% translate "View" %}</a>
</td>
</tr>
{% endfor %}
</tbody>
</table>
{% else %}
<p>{% translate "No jobs for this enquiry." %}</p>
{% endif %}
</div>
<div class="actions">
<script src="{% static 'js/view_enquiry.js' %}"></script> {# Assuming you have this JS file #}
<ul>
<li><button class="addJob" id="enquiry-{{ enquiry.id }}">{% translate "New Job" %}</button></li>
</ul>
</div>
{% comment %} Dialogs - These will require JavaScript to function. The HTML structure is provided. {% endcomment %}
<div id="jobAddedDialog" title="{% translate 'New Job Created' %}" style="display: none;">
{% translate "Job has been created." %}<br>
{% translate "Redirecting you now to fill in the details." %}
</div>
<div id="jobConfirm" title="{% translate 'Are you sure you want to make a new Job' %}" style="display: none;">
{% translate "This will create a new Job and a Job number. Are you sure you want to do this?" %}
</div>
<div id="jobsListDialog" style="display: none;">
{% translate "Select the Job this Invoice is for." %}
<ul id="jobsListUL">
{% for job in jobs %}
<li id="job-{{ job.id }}"><a href="{% url 'document_new_invoice_for_job' enquiry_id=enquiry.id job_id=job.id %}">{{ job.title }}</a></li>
{% endfor %}
</ul>
</div>
<div class="related">
<h3>{% translate "Order Acknowledgements" %}</h3>
{% if order_acknowledgements %}
<table class="quotetable">
<thead>
<tr>
<th>{% translate "Created" %}</th>
<th>{% translate "Issue Date" %}</th>
<th>{% translate "Job" %}</th>
<th class="actions">{% translate "Actions" %}</th>
</tr>
</thead>
<tbody>
{% for oa in order_acknowledgements %}
<tr>
<td>{{ oa.document.created|date:"j M Y H:i"|default_if_none:"" }}</td> {# Assuming OA links to a Document model with 'created' #}
<td>{{ oa.issue_date|date:"j M Y"|default_if_none:"" }}</td>
<td><a href="{% url 'job_detail' oa.job.id %}">{{ oa.job.title }}</a></td>
<td class="actions"><a href="{% url 'document_detail' oa.document.id %}">{% translate "View" %}</a></td>
</tr>
{% endfor %}
</tbody>
</table>
{% else %}
<p>{% translate "No order acknowledgements for this enquiry." %}</p>
{% endif %}
<h4>{% translate "View a quotation to create an Order Acknowledgement" %}</h4>
</div>
<div class="related">
<h3>{{ enquiry.invoices.count }} {% if enquiry.invoices.count == 1 %}{% translate "Invoice" %}{% else %}{% translate "Invoices" %}{% endif %} {% translate "for this Enquiry" %}</h3>
{% if invoices %}
<table class="quotetable">
<thead>
<tr>
<th>{% translate "Issue Date" %}</th>
<th>{% translate "Due Date" %}</th>
<th>{% translate "Invoice Number" %}</th>
<th>{% translate "Job" %}</th>
<th>{% translate "Customer" %}</th>
<th>{% translate "Paid / Unpaid" %}</th>
<th>{% translate "Payment Received Date" %}</th>
<th class="actions">{% translate "Actions" %}</th>
</tr>
</thead>
<tbody>
{% for invoice in invoices %}
<tr class="{% if forloop.counter|divisibleby:2 %}altrow{% endif %}">
<td>{{ invoice.issue_date|date:"j M Y"|default_if_none:"" }}</td>
<td>{{ invoice.due_date|date:"j M Y"|default_if_none:"" }}</td>
<td>{{ invoice.title|default_if_none:"" }}</td>
<td>
{% if invoice.job %}
<a href="{% url 'job_detail' invoice.job.id %}">{{ invoice.job.title }}</a>
{% endif %}
</td>
<td>
{% if invoice.customer %}
<a href="{% url 'customer_detail' invoice.customer.id %}">{{ invoice.customer.name }}</a>
{% endif %}
</td>
<td>
{% if invoice.paid %}
{% translate "PAID" %}
{% else %}
{% translate "UNPAID" %}
{% endif %}
</td>
<td>
{% if invoice.paid %}
{{ invoice.payment_received_date|date:"j M Y"|default_if_none:"" }}
{% else %}
N/A
{% endif %}
</td>
<td class="actions">
<a href="{% url 'document_detail' invoice.document.id %}">{% translate "View" %}</a>
</td>
</tr>
{% endfor %}
</tbody>
</table>
{% else %}
<p>{% translate "No invoices for this enquiry." %}</p>
{% endif %}
</div>
<div class="actions">
<ul>
<li><button class="addInvoice" id="enquiry-invoice-{{ enquiry.id }}">{% translate "New Empty Invoice" %}</button></li>
</ul>
<h4>{% translate "Note: View an OrderAcknowledgement to create an Invoice pre-filled with the same data" %}</h4>
</div>
<div class="related">
<h3>{% translate "Packing Lists for this Enquiry" %}</h3>
{% if packing_lists %}
<table cellpadding="0" cellspacing="0">
<thead>
<tr>
<th>{% translate "Packing List" %}</th>
<th>{% translate "Issue Date" %}</th>
<th class="actions">{% translate "Actions" %}</th>
</tr>
</thead>
<tbody>
{% for packing_list in packing_lists %}
<tr class="{% if forloop.counter|divisibleby:2 %}altrow{% endif %}">
<td>
<a href="{% url 'document_detail' packing_list.document.id %}">{{ packing_list.title }}</a>
</td>
<td>{{ packing_list.issue_date|date:"j M Y"|default_if_none:"" }}</td>
<td class="actions">
<a href="{% url 'document_detail' packing_list.document.id %}">{% translate "View" %}</a>
</td>
</tr>
{% endfor %}
</tbody>
</table>
{% else %}
<p>{% translate "No packing lists for this enquiry." %}</p>
{% endif %}
</div>
<div id="showemail">
{% comment %} This div was empty, perhaps for AJAX content later? {% endcomment %}
</div>
<div class="related">
<h3>
{% translate "Emails for this Enquiry" %} <img src="{% static 'images/internet-mail.png' %}" alt="Email icon">
</h3>
{% if emails %}
{% include 'cmc/partials/email_table.html' with emails=emails %}
{% else %}
<p>{% translate "No emails for this enquiry." %}</p>
{% endif %}
</div>
{% endblock %}
{% block extra_js %}
{# Add any page-specific JavaScript here, especially for the dialogs #}
<script>
document.addEventListener('DOMContentLoaded', function() {
// Basic example for the "New Job" button
const newJobButton = document.querySelector('button.addJob');
if (newJobButton) {
newJobButton.addEventListener('click', function() {
// Implement jobConfirm dialog logic here
// For example, using a simple confirm:
if (confirm(document.getElementById('jobConfirm').title)) {
// Logic to proceed with creating a new job
// This would likely involve an AJAX request or redirecting to a 'new job' URL
// Example: window.location.href = "{% url 'job_add_for_enquiry' enquiry.id %}";
alert('Proceeding to create new job (implement actual logic)');
// Show jobAddedDialog (this needs more sophisticated dialog library like jQuery UI or custom modal)
}
});
}
// Similar setup for addInvoice button and other interactive elements
});
</script>
{% endblock %}