Добавил фильтр статуса на страницу списания
All checks were successful
Deploy MES Core / deploy (push) Successful in 12s
All checks were successful
Deploy MES Core / deploy (push) Successful in 12s
This commit is contained in:
@@ -5,18 +5,32 @@
|
||||
<div class="card-body py-2">
|
||||
<form method="get" class="row g-2 align-items-end">
|
||||
<div class="col-md-auto">
|
||||
<label class="small text-muted mb-1 fw-bold">Выгрузка 1С:</label>
|
||||
<div class="d-flex flex-wrap gap-1">
|
||||
<div>
|
||||
<input type="radio" class="btn-check" name="is_synced" id="ws_all" value="" {% if is_synced != '0' and is_synced != '1' %}checked{% endif %} onchange="this.form.submit()">
|
||||
<label class="btn btn-outline-accent btn-sm" for="ws_all">Все</label>
|
||||
</div>
|
||||
<div>
|
||||
<input type="radio" class="btn-check" name="is_synced" id="ws_no" value="0" {% if is_synced == '0' %}checked{% endif %} onchange="this.form.submit()">
|
||||
<label class="btn btn-outline-secondary btn-sm" for="ws_no">Не выгружено</label>
|
||||
</div>
|
||||
<div>
|
||||
<input type="radio" class="btn-check" name="is_synced" id="ws_yes" value="1" {% if is_synced == '1' %}checked{% endif %} onchange="this.form.submit()">
|
||||
<label class="btn btn-outline-success btn-sm" for="ws_yes">Выгружено</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-md-auto ms-md-auto">
|
||||
<label class="small text-muted mb-1 fw-bold">Период (с):</label>
|
||||
<input type="date" name="start_date" class="form-control form-control-sm bg-body text-body border-secondary" value="{{ start_date }}">
|
||||
<input type="date" name="start_date" class="form-control form-control-sm bg-body text-body border-secondary" value="{{ start_date }}" onchange="this.form.submit()">
|
||||
</div>
|
||||
<div class="col-md-auto">
|
||||
<label class="small text-muted mb-1 fw-bold">Период (по):</label>
|
||||
<input type="date" name="end_date" class="form-control form-control-sm bg-body text-body border-secondary" value="{{ end_date }}">
|
||||
</div>
|
||||
<div class="col-md-auto">
|
||||
<button type="submit" class="btn btn-outline-secondary btn-sm">
|
||||
<i class="bi bi-funnel me-1"></i>Показать
|
||||
</button>
|
||||
<input type="date" name="end_date" class="form-control form-control-sm bg-body text-body border-secondary" value="{{ end_date }}" onchange="this.form.submit()">
|
||||
</div>
|
||||
|
||||
<div class="col-md-auto">
|
||||
<a href="{% url 'writeoffs' %}?reset=1" class="btn btn-outline-secondary btn-sm">
|
||||
<i class="bi bi-arrow-counterclockwise me-1"></i>Сброс
|
||||
@@ -36,6 +50,7 @@
|
||||
{% csrf_token %}
|
||||
<input type="hidden" name="start_date" value="{{ start_date }}">
|
||||
<input type="hidden" name="end_date" value="{{ end_date }}">
|
||||
<input type="hidden" name="is_synced" value="{{ is_synced }}">
|
||||
|
||||
<div class="card-body">
|
||||
{% for card in report_cards %}
|
||||
|
||||
@@ -5148,6 +5148,7 @@ class LegacyWriteOffsView(LoginRequiredMixin, TemplateView):
|
||||
|
||||
start_date = (self.request.GET.get('start_date') or '').strip()
|
||||
end_date = (self.request.GET.get('end_date') or '').strip()
|
||||
is_synced = (self.request.GET.get('is_synced') or '').strip()
|
||||
reset = self.request.GET.get('reset')
|
||||
|
||||
if not start_date or not end_date or reset:
|
||||
@@ -5158,6 +5159,8 @@ class LegacyWriteOffsView(LoginRequiredMixin, TemplateView):
|
||||
|
||||
ctx['start_date'] = start_date
|
||||
ctx['end_date'] = end_date
|
||||
ctx['is_synced'] = is_synced if is_synced in ['0', '1'] else ''
|
||||
ctx['is_synced'] = is_synced if is_synced in ['0', '1'] else ''
|
||||
|
||||
reports_qs = (
|
||||
CuttingSession.objects.select_related('machine', 'operator')
|
||||
@@ -5165,6 +5168,12 @@ class LegacyWriteOffsView(LoginRequiredMixin, TemplateView):
|
||||
.order_by('-date', '-id')
|
||||
)
|
||||
|
||||
if is_synced in ['0', '1']:
|
||||
reports_qs = reports_qs.filter(is_synced_1c=bool(int(is_synced)))
|
||||
|
||||
if is_synced in ['0', '1']:
|
||||
reports_qs = reports_qs.filter(is_synced_1c=bool(int(is_synced)))
|
||||
|
||||
reports = list(
|
||||
reports_qs.prefetch_related(
|
||||
'tasks__task__deal',
|
||||
@@ -6149,6 +6158,7 @@ class WriteOffsView(LoginRequiredMixin, TemplateView):
|
||||
|
||||
start_date = (self.request.GET.get('start_date') or '').strip()
|
||||
end_date = (self.request.GET.get('end_date') or '').strip()
|
||||
is_synced = (self.request.GET.get('is_synced') or '').strip()
|
||||
reset = self.request.GET.get('reset')
|
||||
|
||||
if not start_date or not end_date or reset:
|
||||
@@ -6159,6 +6169,7 @@ class WriteOffsView(LoginRequiredMixin, TemplateView):
|
||||
|
||||
ctx['start_date'] = start_date
|
||||
ctx['end_date'] = end_date
|
||||
ctx['is_synced'] = is_synced if is_synced in ['0', '1'] else ''
|
||||
|
||||
reports_qs = (
|
||||
CuttingSession.objects.select_related('machine', 'operator')
|
||||
@@ -6166,6 +6177,9 @@ class WriteOffsView(LoginRequiredMixin, TemplateView):
|
||||
.order_by('-date', '-id')
|
||||
)
|
||||
|
||||
if is_synced in ['0', '1']:
|
||||
reports_qs = reports_qs.filter(is_synced_1c=bool(int(is_synced)))
|
||||
|
||||
reports = list(
|
||||
reports_qs.prefetch_related(
|
||||
'tasks__task__deal',
|
||||
@@ -6218,6 +6232,9 @@ class WriteOffsView(LoginRequiredMixin, TemplateView):
|
||||
.filter(status__in=['done', 'partial'], date__gte=start_date, date__lte=end_date)
|
||||
.order_by('-date', '-id')
|
||||
)
|
||||
|
||||
if is_synced in ['0', '1']:
|
||||
items_qs = items_qs.filter(is_synced_1c=bool(int(is_synced)))
|
||||
ctx['items'] = list(items_qs)
|
||||
return ctx
|
||||
|
||||
@@ -6241,4 +6258,9 @@ class WriteOffsView(LoginRequiredMixin, TemplateView):
|
||||
|
||||
start_date = (request.POST.get('start_date') or '').strip()
|
||||
end_date = (request.POST.get('end_date') or '').strip()
|
||||
return redirect(f"{reverse_lazy('writeoffs')}?start_date={start_date}&end_date={end_date}")
|
||||
is_synced = (request.POST.get('is_synced') or '').strip()
|
||||
|
||||
url = f"{reverse_lazy('writeoffs')}?start_date={start_date}&end_date={end_date}"
|
||||
if is_synced in ['0', '1']:
|
||||
url += f"&is_synced={is_synced}"
|
||||
return redirect(url)
|
||||
Reference in New Issue
Block a user