Add progress to req_list
This commit is contained in:
parent
7a153c46e6
commit
5ce94214d5
6 changed files with 29261 additions and 27 deletions
|
@ -245,7 +245,7 @@ class ProcessInstance(SluggedModel):
|
|||
'cancelled': 'warning',
|
||||
}
|
||||
color = status_colors.get(self.status, 'secondary')
|
||||
return '<span class="badge bg-{}">{}</span>'.format(color, self.get_status_display())
|
||||
return '<span class="badge bg-label-{}">{}</span>'.format(color, self.get_status_display())
|
||||
|
||||
def get_priority_display_with_color(self):
|
||||
"""نمایش اولویت با رنگ"""
|
||||
|
|
|
@ -144,31 +144,41 @@
|
|||
<th>نماینده</th>
|
||||
<th>استان</th>
|
||||
<th>امور</th>
|
||||
<th>پیشرفت</th>
|
||||
<th>وضعیت</th>
|
||||
<th>تاریخ ایجاد</th>
|
||||
<th>عملیات</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for inst in instances %}
|
||||
{% for item in instances_with_progress %}
|
||||
<tr>
|
||||
<td>{{ inst.code }}</td>
|
||||
<td>{{ inst.process.name }}</td>
|
||||
<td>{{ item.instance.code }}</td>
|
||||
<td>{{ item.instance.process.name }}</td>
|
||||
<td class="text-primary">
|
||||
{% if inst.status == 'completed' %}
|
||||
<a href="{% url 'processes:instance_summary' inst.id %}" class="text-primary">{{ inst.current_step.name|default:"--" }}</a>
|
||||
{% elif inst.current_step %}
|
||||
<a href="{% url 'processes:instance_steps' inst.id %}" class="text-primary">{{ inst.current_step.name }}</a>
|
||||
{% if item.instance.status == 'completed' %}
|
||||
<a href="{% url 'processes:instance_summary' item.instance.id %}" class="text-primary">{{ item.instance.current_step.name|default:"--" }}</a>
|
||||
{% elif item.instance.current_step %}
|
||||
<a href="{% url 'processes:instance_steps' item.instance.id %}" class="text-primary">{{ item.instance.current_step.name }}</a>
|
||||
{% else %}
|
||||
--
|
||||
{% endif %}
|
||||
</td>
|
||||
<td>{{ inst.well.water_subscription_number }}</td>
|
||||
<td>{% if inst.representative %}{{ inst.representative.get_full_name }}{% else %}-{% endif %}</td>
|
||||
<td>{% if inst.well and inst.well.county %}{{ inst.well.county }}{% else %}-{% endif %}</td>
|
||||
<td>{% if inst.well and inst.well.affairs %}{{ inst.well.affairs }}{% else %}-{% endif %}</td>
|
||||
<td>{{ inst.get_status_display_with_color|safe }}</td>
|
||||
<td>{{ inst.jcreated }}</td>
|
||||
<td>{{ item.instance.well.water_subscription_number }}</td>
|
||||
<td>{% if item.instance.representative %}{{ item.instance.representative.get_full_name }}{% else %}-{% endif %}</td>
|
||||
<td>{% if item.instance.well and item.instance.well.county %}{{ item.instance.well.county }}{% else %}-{% endif %}</td>
|
||||
<td>{% if item.instance.well and item.instance.well.affairs %}{{ item.instance.well.affairs }}{% else %}-{% endif %}</td>
|
||||
<td>
|
||||
<div class="d-flex align-items-center">
|
||||
<div class="progress me-2" style="width: 80px; height: 6px;">
|
||||
<div class="progress-bar {% if item.progress_percentage == 100 %}bg-success{% elif item.progress_percentage >= 70 %}bg-info{% elif item.progress_percentage >= 40 %}bg-warning{% else %}bg-secondary{% endif %}" role="progressbar" style="width: {{ item.progress_percentage }}%;" aria-valuenow="{{ item.progress_percentage }}" aria-valuemin="0" aria-valuemax="100">
|
||||
</div>
|
||||
</div>
|
||||
<small class="text-muted">{{ item.progress_percentage }}%</small>
|
||||
</div>
|
||||
</td>
|
||||
<td>{{ item.instance.get_status_display_with_color|safe }}</td>
|
||||
<td>{{ item.instance.jcreated }}</td>
|
||||
<td>
|
||||
<div class="d-inline-block">
|
||||
<a href="javascript:;" class="btn btn-icon dropdown-toggle hide-arrow" data-bs-toggle="dropdown">
|
||||
|
@ -176,19 +186,19 @@
|
|||
</a>
|
||||
<ul class="dropdown-menu dropdown-menu-end m-0">
|
||||
<li>
|
||||
{% if inst.status == 'completed' %}
|
||||
<a href="{% url 'processes:instance_summary' inst.id %}" class="dropdown-item">
|
||||
{% if item.instance.status == 'completed' %}
|
||||
<a href="{% url 'processes:instance_summary' item.instance.id %}" class="dropdown-item">
|
||||
<i class="bx bx-show me-1"></i>مشاهده گزارش
|
||||
</a>
|
||||
{% else %}
|
||||
<a href="{% url 'processes:instance_steps' inst.id %}" class="dropdown-item">
|
||||
<a href="{% url 'processes:instance_steps' item.instance.id %}" class="dropdown-item">
|
||||
<i class="bx bx-show me-1"></i>مشاهده جزئیات
|
||||
</a>
|
||||
{% endif %}
|
||||
</li>
|
||||
<div class="dropdown-divider"></div>
|
||||
<li>
|
||||
<a href="#" class="dropdown-item text-danger" data-instance-id="{{ inst.id }}" data-instance-code="{{ inst.code }}" onclick="deleteRequest(this.getAttribute('data-instance-id'), this.getAttribute('data-instance-code'))">
|
||||
<a href="#" class="dropdown-item text-danger" data-instance-id="{{ item.instance.id }}" data-instance-code="{{ item.instance.code }}" onclick="deleteRequest(this.getAttribute('data-instance-id'), this.getAttribute('data-instance-code'))">
|
||||
<i class="bx bx-trash me-1"></i>حذف
|
||||
</a>
|
||||
</li>
|
||||
|
@ -198,7 +208,7 @@
|
|||
</tr>
|
||||
{% empty %}
|
||||
<tr>
|
||||
<td colspan="9" class="text-center text-muted">موردی ثبت نشده است</td>
|
||||
<td colspan="11" class="text-center text-muted">موردی ثبت نشده است</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
|
|
|
@ -18,16 +18,32 @@ from wells.models import WaterMeterManufacturer
|
|||
@login_required
|
||||
def request_list(request):
|
||||
"""نمایش لیست درخواستها با جدول و مدال ایجاد"""
|
||||
instances = ProcessInstance.objects.select_related('well', 'representative', 'requester').filter(is_deleted=False).order_by('-created')
|
||||
instances = ProcessInstance.objects.select_related('well', 'representative', 'requester').prefetch_related('step_instances__step').filter(is_deleted=False).order_by('-created')
|
||||
processes = Process.objects.filter(is_active=True)
|
||||
manufacturers = WaterMeterManufacturer.objects.all().order_by('name')
|
||||
|
||||
# Calculate progress for each instance
|
||||
instances_with_progress = []
|
||||
for instance in instances:
|
||||
total_steps = instance.process.steps.count()
|
||||
completed_steps = instance.step_instances.filter(status='completed').count()
|
||||
progress_percentage = (completed_steps / total_steps * 100) if total_steps > 0 else 0
|
||||
|
||||
instances_with_progress.append({
|
||||
'instance': instance,
|
||||
'progress_percentage': round(progress_percentage),
|
||||
'completed_steps': completed_steps,
|
||||
'total_steps': total_steps,
|
||||
})
|
||||
|
||||
# Summary stats for header cards
|
||||
total_count = instances.count()
|
||||
completed_count = instances.filter(status='completed').count()
|
||||
in_progress_count = instances.filter(status='in_progress').count()
|
||||
pending_count = instances.filter(status='pending').count()
|
||||
|
||||
return render(request, 'processes/request_list.html', {
|
||||
'instances': instances,
|
||||
'instances_with_progress': instances_with_progress,
|
||||
'customer_form': CustomerForm(),
|
||||
'well_form': WellForm(),
|
||||
'processes': processes,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue