fix counter nazar, improve check, call button
This commit is contained in:
1 parent
36364447c7
commit
04ddc701a3
6 files changed
+578
-223
No files matched your search
@@ -1,24 +1,43 @@
|
||||
from django.db.models import Count, Sum
|
||||
from django.db.models import Q
|
||||
from django.db.models import Count, Sum, Q
|
||||
import os
|
||||
import datetime
|
||||
|
||||
from .models import *
|
||||
|
||||
def dashBoxData(request):
|
||||
|
||||
|
||||
bazdid = os.environ.get('bazdid', 9)
|
||||
|
||||
debit = Article.objects.filter().aggregate(Sum('debit'))['debit__sum']
|
||||
credit = Article.objects.filter().aggregate(Sum('credit'))['credit__sum']
|
||||
|
||||
try:
|
||||
mandehesab = debit - credit
|
||||
except:
|
||||
mandehesab = 0
|
||||
|
||||
countCustomers = Customer.objects.all().count()
|
||||
allUsers = User.objects.filter().exclude(username='admin').exclude(username='fesahat')
|
||||
ActionCount = Action.objects.filter(forUser=request.user.id, status='waite').count()
|
||||
rezayatCount = Action.objects.exclude(actionType='vosol').filter(Q(nazar='') | Q(nazar=None) & Q(status='finish')).count()
|
||||
|
||||
# ---------------------------------------------------------
|
||||
# بخش اصلاح شده برای شمارش دقیق نظرسنجیهای در انتظار
|
||||
# ---------------------------------------------------------
|
||||
now = datetime.datetime.now()
|
||||
dt_30_days_ago = now - datetime.timedelta(days=30)
|
||||
dt_60_days_ago = now - datetime.timedelta(days=60)
|
||||
|
||||
rezayatCount = Action.objects.exclude(actionType='vosol').filter(
|
||||
status='finish',
|
||||
nazarDT__isnull=True, # نظرسنجی هنوز نهایی نشده
|
||||
createdDT__gte=dt_60_days_ago # حداکثر ۶۰ روز از ایجاد گذشته باشد
|
||||
).filter(
|
||||
Q(finishDateTime__isnull=True) | Q(finishDateTime__gte=dt_30_days_ago) # حداکثر ۳۰ روز از اتمام گذشته باشد
|
||||
).filter(
|
||||
Q(nextNazarDT__isnull=True) | Q(nextNazarDT__lte=now) # موعد پیگیری رسیده یا تعویقی نداشته باشد
|
||||
).count()
|
||||
# ---------------------------------------------------------
|
||||
|
||||
try:
|
||||
entezarbazdid = CacheTable.objects.get(key='9mahbazdid').value
|
||||
except Exception as exp:
|
||||
@@ -33,4 +52,5 @@ def dashBoxData(request):
|
||||
'entezarbazdid': entezarbazdid,
|
||||
'bazdid': bazdid
|
||||
}
|
||||
|
||||
return data
|
||||
Reference in new issue
Block a user