|
|
|
|
@@ -133,75 +133,6 @@ def visit_view(request):
|
|
|
|
|
'form_action': 'add-order'
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
@login_required
|
|
|
|
|
def main(request, day, month, year):
|
|
|
|
|
if day == None:
|
|
|
|
|
day = str(date.today().day)
|
|
|
|
|
if month == None:
|
|
|
|
|
month = str(date.today().month)
|
|
|
|
|
if year == None:
|
|
|
|
|
year = str(date.today().year)
|
|
|
|
|
|
|
|
|
|
d,m,y=int(day),int(month), int(year)
|
|
|
|
|
|
|
|
|
|
attend_list = Attendance.objects.all().order_by('date')
|
|
|
|
|
filtered_attend_list=get_filtered_list(attend_list, year, month)
|
|
|
|
|
|
|
|
|
|
p_date = datetime.strptime(day+'/'+month+'/'+year, '%d/%m/%Y')
|
|
|
|
|
order_list = Order.objects.filter(date=p_date).order_by('id')
|
|
|
|
|
month_order_list=Order.objects.filter(date__range=(date(y,m,1),date(y,m,calendar.monthrange(y,m)[1]))).values('date').annotate(Count('product'),Sum('price'))
|
|
|
|
|
|
|
|
|
|
plan = OrderPlan.objects.all()
|
|
|
|
|
filtered_plan = get_filtered_list(plan, year, month)
|
|
|
|
|
month_plan=0
|
|
|
|
|
if len(filtered_plan) > 0:
|
|
|
|
|
month_plan=filtered_plan[0].plan
|
|
|
|
|
|
|
|
|
|
schedule = Schedule.objects.all().order_by('date')
|
|
|
|
|
filtered_schedule = get_filtered_list(schedule, year, month)
|
|
|
|
|
|
|
|
|
|
month_days={i: {'date': custom_date(int(year),int(month),i)} for i in range(1,calendar.monthrange(int(year),int(month))[1]+1)}
|
|
|
|
|
|
|
|
|
|
for l in filtered_attend_list:
|
|
|
|
|
month_days[l.date.day]['attend']=l
|
|
|
|
|
|
|
|
|
|
for s in filtered_schedule:
|
|
|
|
|
if 'designers' in month_days[s.date.day]:
|
|
|
|
|
des=', '.join((month_days[s.date.day]['designers'], ' '.join((s.designer.first_name, s.designer.last_name))))
|
|
|
|
|
month_days[s.date.day]['designers'] = des
|
|
|
|
|
else:
|
|
|
|
|
month_days[s.date.day]['designers'] = ' '.join((s.designer.first_name, s.designer.last_name))
|
|
|
|
|
|
|
|
|
|
for order in month_order_list:
|
|
|
|
|
month_days[order['date'].day]['orders_count'] = order['product__count']
|
|
|
|
|
month_days[order['date'].day]['orders_price'] = order['price__sum']
|
|
|
|
|
|
|
|
|
|
month_days_values = month_days.values()
|
|
|
|
|
|
|
|
|
|
sum_calls = sum(l.calls for l in filtered_attend_list)
|
|
|
|
|
sum_visits = sum(l.visits for l in filtered_attend_list)
|
|
|
|
|
sum_orders = sum(l['orders_count'] for l in month_days_values if 'orders_count' in l)
|
|
|
|
|
sum_price = sum(l['orders_price'] for l in month_days_values if 'orders_price' in l)
|
|
|
|
|
|
|
|
|
|
sum_order_price = sum(l.price for l in order_list)
|
|
|
|
|
plan_balance = month_plan-sum_price
|
|
|
|
|
|
|
|
|
|
d_date = p_date.strftime("%d/%m/%Y")
|
|
|
|
|
|
|
|
|
|
t = loader.get_template('asuzr/attend_order.html')
|
|
|
|
|
c = RequestContext(request,{
|
|
|
|
|
'attend_list': month_days_values,
|
|
|
|
|
'order_list': order_list,
|
|
|
|
|
'sum_calls': sum_calls,
|
|
|
|
|
'sum_visits': sum_visits,
|
|
|
|
|
'sum_orders': sum_orders,
|
|
|
|
|
'sum_price': sum_price,
|
|
|
|
|
'sum_order_price': sum_order_price,
|
|
|
|
|
'plan': month_plan,
|
|
|
|
|
'balance': plan_balance,
|
|
|
|
|
'd_date': d_date,
|
|
|
|
|
})
|
|
|
|
|
return HttpResponse(t.render(c))
|
|
|
|
|
|
|
|
|
|
@log_view_call
|
|
|
|
|
@login_required
|
|
|
|
|
@@ -297,19 +228,29 @@ def prod_plan_view(request):
|
|
|
|
|
week_days = {i.weekday(): {'date': custom_date(i.year,i.month,i.day)} for i in days}
|
|
|
|
|
prodplan_list = ProdPlan.objects.filter(start_date__range = (sdate,edate))
|
|
|
|
|
|
|
|
|
|
for prodplan in prodplan_list:
|
|
|
|
|
week_days[prodplan.start_date.weekday()]['prodplan'] = prodplan
|
|
|
|
|
tables = []
|
|
|
|
|
for week_day in week_days:
|
|
|
|
|
tdate = week_days[week_day]['date']
|
|
|
|
|
prodplan_list = ProdPlan.objects.filter(start_date = tdate)
|
|
|
|
|
tables.append(ProdPlanTable(prodplan_list))
|
|
|
|
|
tables[week_day].verbose_name = ', '.join((tdate.strftime('%d.%m.%Y'), tdate.weekday_name))
|
|
|
|
|
|
|
|
|
|
table = ProdPlanTable(week_days.values())
|
|
|
|
|
title = u'Производственный план на %s - %s' % (sdate.strftime('%d.%m.%Y'), edate.strftime('%d.%m.%Y'))
|
|
|
|
|
date_form = DateForm({'date':curr_date})
|
|
|
|
|
add_form = ProdPlanForm()
|
|
|
|
|
RequestConfig(request).configure(table)
|
|
|
|
|
return render(request, 'asuzr/table.html', {'table': table, 'title': title, 'dateform': date_form, 'add_form': add_form, 'form_action' : 'add-plan-item'})
|
|
|
|
|
for table in tables:
|
|
|
|
|
RequestConfig(request).configure(table)
|
|
|
|
|
return render(request, 'asuzr/table_n.html', {'tables': tables, 'title': title, 'dateform': date_form, 'add_form': add_form, 'form_action' : 'add-plan-item'})
|
|
|
|
|
|
|
|
|
|
def prod_plan_add_item(request):
|
|
|
|
|
return redirect(prod_plan_view)
|
|
|
|
|
|
|
|
|
|
def create_plan_item_if_need(date):
|
|
|
|
|
plan_item, created = ProdPlan.objects.get_or_create(start_date = date,
|
|
|
|
|
defaults={'end_date': date})
|
|
|
|
|
if created:
|
|
|
|
|
plan_item.save()
|
|
|
|
|
|
|
|
|
|
@login_required
|
|
|
|
|
def log_view(request):
|
|
|
|
|
log = LogEntry.objects.all()
|
|
|
|
|
|