charts , phonenumber and profile picture fix #212

Merged
ismail merged 4 commits from frontend into main 2025-08-31 19:33:14 +03:00
7 changed files with 50 additions and 30 deletions

View File

@ -1711,8 +1711,11 @@ class Customer(models.Model):
national_id = models.CharField(
max_length=10, unique=True, verbose_name=_("National ID"), null=True, blank=True
)
phone_number = PhoneNumberField(
region="SA", unique=True, verbose_name=_("Phone Number")
phone_number = models.CharField(
max_length=255,
verbose_name=_("Phone Number"),
validators=[SaudiPhoneNumberValidator()],
)
address = models.CharField(
max_length=200, blank=True, null=True, verbose_name=_("Address")
@ -1723,7 +1726,7 @@ class Customer(models.Model):
blank=True,
null=True,
verbose_name=_("Image"),
default="default-image/user-jpg",
default="default-image/user.jpg",
)
thumbnail = ImageSpecField(
source="image",

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 MiB

View File

@ -36,7 +36,7 @@
{% if token_fail %}
{% url 'account_reset_password' as passwd_reset_url %}
<p>
{% trans "The password reset link was invalid, possibly because it has already been used. Please request a" %} <a href="{{ passwd_reset_url }}">{% trans "new password reset." %}</a>{% endblocktrans %}
{% trans "The password reset link was invalid, possibly because it has already been used. Please request a" %} <a href="{{ passwd_reset_url }}">{% trans "new password reset." %}</a>
</p>
{% else %}
<form method="POST" action="{{ action_url }}" class="form">

View File

@ -26,8 +26,9 @@
<div class="text-center">
<h3 class="mb-4">{% trans "Change Password" %}</h3>
<p class="fs-9 fw-bold text-success">
{% trans 'Your password is now changed.' %} <span class="far fa-check-circle ms-1"></span>
{% trans 'Congratulations, Your password is now changed.' %} <span class="far fa-check-circle ms-1"></span>
</p>
<p><a href="{% url 'account_login' %}">{% trans 'Click here to Login'%}</a></p>
</div>
</div>
</div>

View File

@ -10,12 +10,12 @@
<h2 class="h3 fw-bold mb-3 mb-md-0">
{% if request.is_dealer %}
{% trans "Business Health Dashboard" %}
{% elif request.is_manger %}
{% trans "Manager Dashboard" %}
{% elif request.is_inventory %}
{% elif request.is_accountant and not request.is_dealer and not request.is_manager %}
{% trans "Accountant Dashboard" %}
{% elif request.is_inventory and not request.is_dealer and not request.is_manager %}
{% trans "Inventory Dashboard" %}
{% else %}
{% trans "Accountant Dashboard" %}
{% trans "Manager Dashboard" %}
{% endif %}
<i class="fas fa-chart-area text-primary ms-2"></i>
</h2>
@ -49,9 +49,10 @@
<div class="row g-4 mb-5">{% include 'dashboards/partials//financial_data_cards.html' %}</div>
<div class="row g-4 mb-5">{% include 'dashboards/partials/chart.html' %}</div>
</div>
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
{% endblock content %}
{% block customJS %}
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
<script>
// Define a color palette that aligns with the Phoenix template
const primaryColor = '#7249b6';
@ -59,21 +60,28 @@
const successColor = '#00d074';
const dangerColor = '#e63757';
const chartColors = [
'#7249b6', '#00d074', '#e63757', '#17a2b8', '#ffc107',
'#8193a6', '#28a745', '#6c757d', '#fd7e14', '#dc3545',
'#20c997', '#6f42c1', '#e83e8c', '#6610f2', '#007bff',
'#495057'
];
'#7249b6', '#00d074', '#e63757', '#17a2b8', '#ffc107',
'#8193a6', '#28a745', '#6c757d', '#fd7e14', '#dc3545',
'#20c997', '#6f42c1', '#e83e8c', '#6610f2', '#007bff',
'#495057', '#0d6efd', '#6610f2', '#6f42c1', '#d63384',
'#dc3545', '#fd7e14', '#ffc107', '#198754', '#20c997',
'#0dcaf0', '#0d6efd', '#6c757d', '#adb5bd', '#6c757d',
'#5a5c69', '#36b9cc', '#1cc88a', '#f6c23e', '#e74a3b',
'#858796', '#f8f9fc', '#2c9faf', '#4e73df', '#845ef2',
'#39e6a9', '#4d4f79', '#9f1d35', '#2a5a5b', '#f77f00',
'#3282b8', '#00bcd4', '#009688', '#4caf50', '#8bc34a',
'#ffeb3b', '#ff9800', '#ff5722', '#795548', '#9e9e9e'
];
// Pass translated strings from Django to JavaScript
const translatedStrings = {
monthlyCarsSoldLabel: "{% trans 'Total Cars Sold' %}",
monthlyRevenueLabel: "{% trans 'Monthly Revenue' %}",
monthlyNetProfitLabel: "{% trans 'Monthly Net Profit' %}",
salesByMakeLabel: "{% trans 'Car Count by Make' %}",
salesByModelPrefix: "{% trans 'Cars Sold by model' %}",
salesByMakeLabel: "{% trans 'Car Sale by Make' %}",
salesByModelPrefix: "{% trans 'Car Sale by Model' %}",
inventoryByMakeLabel: "{% trans 'Car Count by Make' %}",
inventoryByModelLabel: "{% trans 'Cars in Inventory' %}",
inventoryByModelLabel: "{% trans 'Car Count by Model' %}",
jan: "{% trans 'Jan' %}",
feb: "{% trans 'Feb' %}",
mar: "{% trans 'Mar' %}",
@ -89,8 +97,17 @@
cars: "{% trans 'cars' %}"
};
function getChartColors(count) {
const colors = [];
for (let i = 0; i < count; i++) {
colors.push(chartColors[i % chartColors.length]);
}
return colors;
};
// Monthly Cars Sold (Bar Chart)
{% if request.is_dealer or request.is_manager or request.is_accountant %}
const ctx1 = document.getElementById('CarsSoldByMonthChart').getContext('2d');
new Chart(ctx1, {
type: 'bar',
@ -211,15 +228,9 @@
}
}
});
// Sales by Make (Pie Chart)
function getChartColors(count) {
const colors = [];
for (let i = 0; i < count; i++) {
colors.push(chartColors[i % chartColors.length]);
}
return colors;
}
const ctx3 = document.getElementById('salesByBrandChart').getContext('2d');
new Chart(ctx3, {
@ -315,10 +326,11 @@
}
});
}
{% endif %}
// -----------------------------------------------------------
// 5. Inventory by Make (Pie Chart)
// -----------------------------------------------------------
{% if request.is_dealer or request.is_manager or request.is_inventory %}
const ctxInventoryMake = document.getElementById('inventoryByMakeChart').getContext('2d');
new Chart(ctxInventoryMake, {
type: 'pie',
@ -423,5 +435,6 @@
messageInventoryModel.style.display = 'flex';
}
}
{% endif %}
</script>
{% endblock %}

View File

@ -60,6 +60,7 @@
<button type="submit" class="btn btn-primary">{% trans "Go" %}</button>
<input type="hidden" name="start_date" value="{{ start_date|date:'Y-m-d' }}">
<input type="hidden" name="end_date" value="{{ end_date|date:'Y-m-d' }}">
<input type="hidden" name="make_inventory" value="{{ selected_make_inventory|default:"" }}">
</form>
</div>
{%if selected_make_sales%}
@ -70,7 +71,6 @@
<div class="card-body" style="height: 400px;">
<p class="ms-2">{% trans "Please Select a Make from above to see the Statistics" %}</p>
</div>
{% endif %}
</div>
</div>
@ -108,6 +108,9 @@
</select>
</div>
<button type="submit" class="btn btn-primary">{% trans "Go" %}</button>
<input type="hidden" name="start_date" value="{{ start_date|date:'Y-m-d' }}">
<input type="hidden" name="end_date" value="{{ end_date|date:'Y-m-d' }}">
<input type="hidden" name="make_sold" value="{{ selected_make_sales|default:"" }}">
</form>
</div>
{%if selected_make_inventory%}
@ -118,9 +121,9 @@
<div class="card-body" style="height: 400px;">
<p class="ms-2">{% trans "Please Select a Make from above to see the Statistics" %}</p>
</div>
{% endif %}
</div>
</div>
</div>
{% endif %}
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>

View File

@ -92,7 +92,7 @@
{% endif %}
{% else %}
<button class="dropdown-item text-warning-dark" disabled>
<span class="fas fa-exclamation-triangle me-1"></span>{% trans Fulfill the PO Before Viewing Inventory %}
<span class="fas fa-exclamation-triangle me-1"></span>{% trans "Fulfill the PO Before Viewing Inventory" %}
</button>
{% endif %}
</div>