Exemple #1
0
def report_agent_stat_month(request, agent, year, month, excel=0): #done
	agent = get_object_or_404(Agent, slug=agent)
	title = agent.name + " Performance: " +month_display(month) + " "+ year
	team = Teams.objects.get(name=agent.teamid)
	targets = Targets.objects.get(name=team.targets)
	stats = Dstats.objects.filter(agent=agent).filter(isoyear=year).filter(month=month)
	totals = stats.aggregate(Sum('totalapps'), Sum('calltime'), Sum('callattempts'), Sum('prodhours'), Sum('sickhours'), Sum('innovhours'))
	average = {}

	if totals['prodhours__sum'] > 0:
		average['calltime'] = int(totals['calltime__sum'] / (totals['prodhours__sum'] / targets.hours))
		average['callattempts'] = int(totals['callattempts__sum'] / (totals['prodhours__sum'] / targets.hours))
		average['apps'] = totals['totalapps__sum'] / ((totals['prodhours__sum'] + totals['sickhours__sum'] + totals['innovhours__sum'])/ targets.hours)

	if excel > 0:
		template = 'reports/excel/agentreport.html'
		context = RequestContext(request, {'title':title, 'average':average, 'totals':totals, 'stats':stats})

		response = render_to_response(template, context)

		filename = "%sagentperformancereport%s%s.xls" % (agent.slug, year, month)
		response['Content-Disposition'] = 'attachment; filename='+filename
		response['Content-Type'] = 'application/vnd.ms-excel; charset=utf-8'

		return response
	else:
		url = "/reports/agent/excel/"+agent.slug+"/"+year+"/"+month
		template = 'reports/agentreport.html'
		context = RequestContext(request, {'url':url, 'title':title, 'average':average, 'totals':totals, 'stats':stats})
	    
		response = render_to_response(template, context)
	    
		return response
Exemple #2
0
def academy_quarter_winners(request, year, quarter):
	quarters = {1:['jan', 'feb', 'mar'], 2:['apr', 'may', 'jun'], 3:['jul', 'aug', 'sep'], 4:['oct', 'nov', 'dec']}
	run = quarters[int(quarter)]
	display = []
	for month in run:
		display.append(month_display(month))

	academy =[]
	academy.append(['Chris Thomas',	2,	0,	0,	0,	6])
	academy.append(['Daryl Bennett',	2,	0,	0,	0,	6])
	academy.append(['James Wildman',	2,	0,	0,	0,	6])
	academy.append(['Jo Humphreys',	2,	0,	0,	0,	6])
	academy.append(['Jodie Gaul',	2,	0,	0,	0,	6])
	academy.append(['Stacey Taylor',	2,	0,	0,	0,	6])
	academy.append(['Hugh Kitchen',	1,	1,	0,	0,	5])
	academy.append(['Jason Whewell',	1,	1,	0,	0,	5])
	academy.append(['Kelly Heath',	1,	1,	0,	0,	5])
	academy.append(['Lee Weaver',	1,	1,	0,	0,	5])
	academy.append(['Loreen Wilson',	1,	1,	0,	0,	5])
	academy.append(['Daniel Phillips',	0,	2,	0,	0,	4])
	academy.append(['Dean Stower',	0,	2,	0,	0,	4])
	academy.append(['Matt Shaw',	1,	0,	1,	0,	4])
	academy.append(['Mike Brain',	0,	2,	0,	0,	4])
	academy.append(['Sam Bradley',	1,	0,	1,	0,	4])
	academy.append(['Emma Dickinson',	0,	1,	1,	0,	3])
	academy.append(['Gary Kenward',	0,	1,	1,	0,	3])
	academy.append(['James Walley',	0,	1,	1,	0,	3])
	academy.append(['John Leonard',	0,	1,	1,	0,	3])
	academy.append(['Lamont Adams',	1,	0,	0,	1,	3])
	academy.append(['Nicola Carleton',	0,	1,	1,	0,	3])
	academy.append(['Rebecca Shaw',	0,	1,	1,	0,	3])
	academy.append(['Carl Waite',	0,	0,	2,	0,	2])
	academy.append(['Gemma Ball',	0,	0,	2,	0,	2])
	academy.append(['Emma Leslie',	0,	0,	1,	1,	1])
	academy.append(['Emma Robinson',	0,	0,	1,	1,	1])
	academy.append(['Gary Goodwin',	0,	0,	1,	1,	1])
	academy.append(['Lee Nichol',	0,	0,	1,	1,	1])
	academy.append(['Rebecca Hill',	0,	0,	1,	1,	1])
	academy.append(['Alex Widgery',	0,	0,	0,	2,	0])
	academy.append(['Audrey Roberts',	0,	0,	0,	2,	0])
	academy.append(['Chris Dixon',	0,	0,	0,	1,	0])
	academy.append(['Dwayne Patterson',	0,	0,	0,	2,	0])
	academy.append(['Hellen Molyneux',	0,	0,	0,	2,	0])
	academy.append(['Louise Batchelor',	0,	0,	0,	1,	0])
	academy.append(['Louise Gallon',	0,	0,	0,	2,	0])
	academy.append(['Nathan Dyer',	0,	0,	0,	2,	0])

	template = 'academy/quarterwinners.html'
	context = RequestContext(request, {'year':year, 'quarter':quarter, 'display':display, 'academy':academy})

	response = render_to_response(template, context)

	return response
Exemple #3
0
def report_team_stat_month(request, team, year, month, excel=0): #done
	team = get_object_or_404(Teams, slug=team)
	title = team.name + " Performance: " +month_display(month) + " "+ year
	agentlist = Agent.objects.filter(haveleft=0).filter(teamid=team).filter(agenttype=0)
	supervisor = Supers.objects.get(name=team.supervisor)
	stats = Dstats.objects.filter(team=team).filter(isoyear=year).filter(month=month)
	targets = Targets.objects.get(name=team.targets)
	totals = stats.aggregate(Sum('totalapps'), Sum('calltime'), Sum('callattempts'), Sum('prodhours'), Sum('sickhours'), Sum('innovhours'))
	average = {}
	agentaverage = {}

	if totals['prodhours__sum'] > 0:
		average['calltime'] = int(totals['calltime__sum'] / (totals['prodhours__sum'] / targets.hours))
		average['callattempts'] = int(totals['callattempts__sum'] / (totals['prodhours__sum'] / targets.hours))
		average['apps'] = totals['totalapps__sum'] / ((totals['prodhours__sum'] + totals['sickhours__sum'] + totals['innovhours__sum'])/ targets.hours)

	appstable = []
	for staff in agentlist:
		qapps = QualifiedApps.objects.filter(year=year).filter(agent=staff).filter(month=month).aggregate(Sum('qualifiedapps'))
		appstable.append([staff.name, qapps['qualifiedapps__sum']])

	for agent in agentlist:
		statslist = []
		agentstats = stats.filter(agent=agent).aggregate(Sum('totalapps'), Sum('calltime'), Sum('callattempts'), Sum('prodhours'), Sum('sickhours'), Sum('innovhours'))
		if agentstats['prodhours__sum'] > 0:
			calltime = int(agentstats['calltime__sum'] / (agentstats['prodhours__sum'] / targets.hours))
			callattempts = int(agentstats['callattempts__sum'] / (agentstats['prodhours__sum'] / targets.hours))
			apps = agentstats['totalapps__sum'] / ((agentstats['prodhours__sum'] + agentstats['sickhours__sum'] + agentstats['innovhours__sum'])/ targets.hours)
			totalapps = agentstats['totalapps__sum']
			statslist.append([calltime, callattempts, apps, totalapps])
		agentaverage[agent.name] = statslist

	if excel > 0:
		template = 'reports/excel/teamreport.html'
		context = RequestContext(request, {'qapps':appstable, 'title':title, 'team':team, 'agentlist':agentlist, 'super':supervisor, 'totals':totals, 'average':average, 'agentaverage':agentaverage})

		response = render_to_response(template, context)

		filename = "%sperformancereport%s%s.xls" % (team.slug, year, month)
		response['Content-Disposition'] = 'attachment; filename='+filename
		response['Content-Type'] = 'application/vnd.ms-excel; charset=utf-8'

		return response

	else:
		url = "/reports/team/excel/"+team.slug+"/"+year+"/"+month
		template = 'reports/teamreport.html'
		context = RequestContext(request, {'url':url, 'qapps':appstable, 'title':title, 'team':team, 'agentlist':agentlist, 'super':supervisor, 'totals':totals, 'average':average, 'agentaverage':agentaverage})
	    
		response = render_to_response(template, context)
	    
		return response
Exemple #4
0
def stats_month(request, year, month): #done
	stat = monthly_stats(year, month)

	title = "Agent Stats: " + month_display(month) + " " + year
	switch = "/stats/team/"+year+"/"+month
	switchtype = "Team"

	template = 'stats/stats.html'
	context = RequestContext(request, {'title':title, 'tstats':stat, 'switch':switch, 'switchtype':switchtype})
    
	response = render_to_response(template, context)
    
	return response
Exemple #5
0
def stats_team_day(request, year, month, day): #done
	stats = team_daily_stats(year, month, day)

	date = '/'.join([day, month_display(month), year])
	title = "Team Stats: " + date
	switch = "/stats/"+year+"/"+month+"/"+day
	switchtype = "Agent"

	template = 'stats/stats.html'
	context = RequestContext(request, {'tstats':stats['tstats'], 'totals':stats['totals'], 'title':title, 'switch':switch, 'switchtype':switchtype})
    
	response = render_to_response(template, context)
    
	return response
Exemple #6
0
def academy_month_leaderboard(request, year, month):
	"""
	Used to request a month's academy leaderboard
	"""
	display = month_display(month)

	academy = academy_month(month, year)
	academy.sort(key=sort_inner)

	template = 'academy/table.html'
	context = RequestContext(request, {'year':year, 'month':display, 'academy':academy})
    
	response = render_to_response(template, context)
    
	return response
Exemple #7
0
def academy_month_winners(request, year, month):
	"""
	Used to request a month's academy presentation
	"""
	display = month_display(month)

	academy = academy_month(month, year)
	academy.sort(key=sort_inner, reverse=True)

	template = 'academy/presentation.html'
	context = RequestContext(request, {'year':year, 'month':display, 'academy':academy})
    
	response = render_to_response(template, context)
    
	return response
Exemple #8
0
def academy_current_leaderboard(request):
	"""
	This function gets the current date - 2 weeks and then bases the academy off the month given by that date. and then creates a leaderboard
	"""
	thedate = datetime.today()-timedelta(days=14)
	month = thedate.strftime("%b").lower()
	year = thedate.strftime("%Y").lower()
	display = month_display(month)

	academy = academy_month(month, year)
	academy.sort(key=sort_inner)

	template = 'academy/table.html'
	context = RequestContext(request, {'month':display, 'year':year, 'academy':academy})
    
	response = render_to_response(template, context)
    
	return response
Exemple #9
0
def academy_current_winners(request):
	"""
	This function gets the current date - 2 weeks and then bases the academy off the month given by that date. And then places it in the presentation
	"""
	thedate = datetime.today()-timedelta(days=14)
	month = thedate.strftime("%b").lower()
	year = thedate.strftime("%Y").lower()
	display = month_display(month)

	academy = academy_month(month, year)
	academy.sort(key=sort_inner, reverse=True)

	template = 'academy/presentation.html'
	context = RequestContext(request, {'month':display, 'year':year, 'academy':academy})
    
	response = render_to_response(template, context)
    
	return response
Exemple #10
0
def report_team_stat_day(request, team, year, month, day): 
	team = get_object_or_404(Teams, slug=team)
	agents = Agent.objects.filter(teamid=team).filter(haveleft=0)
	title = team.name + " Day Breakdown: " + day + "/" + month_display(month) + "/"+ year

	var = [year, month_number(month), day]
	date = '-'.join(var)

	stats = Dstats.objects.filter(team=team).filter(date=date)
	teamtotals = stats.aggregate(Sum('totalapps'), Sum('calltime'), Sum('callattempts'), Sum('prodhours'), Sum('sickhours'))


	template = 'reports/breakdown.html'
	context = RequestContext(request, {"title":title, 'team':team, })
    
	response = render_to_response(template, context)
    
	return response
Exemple #11
0
def stats_this_month(request): #done
	thedate = datetime.today()-timedelta(days=1)
	if thedate.isoweekday() == 7:
		thedate = datetime.today()-timedelta(days=3)

	month = month_number(thedate.strftime("%b").lower())
	year = thedate.strftime("%Y")

	stat = monthly_stats(year, thedate.strftime("%b").lower())

	title = "Agent Stats: " + month_display(thedate.strftime("%b").lower()) + " " + year
	switch = "/stats/team/"+str(year)+"/"+thedate.strftime("%b").lower()
	switchtype = "Team"

	template = 'stats/stats.html'
	context = RequestContext(request, {'title':title, 'tstats':stat, 'switch':switch, 'switchtype':switchtype})
    
	response = render_to_response(template, context)
    
	return response
Exemple #12
0
def team_page(request, team):
	user = request.user.get_profile()
	type = int(user.agenttype)
	if not request.user.has_perm('agents.super'):
		team = Teams.objects.get(name=user.teamid)
		slug = team.slug
		url = "/team/" + slug + "/info"
		return HttpResponseRedirect(url)

	team = get_object_or_404(Teams, slug=team)
	agent  = Agent.objects.filter(teamid__pk=team.pk).filter(agenttype=0).filter(haveleft=0)
	super = Supers.objects.get(pk=team.supervisor_id)
	targets =  Targets.objects.get(name=team.targets)

	thedate = datetime.today()-timedelta(days=1)
	if thedate.isoweekday() == 7:
		thedate = datetime.today()-timedelta(days=3)

	week = int(thedate.isocalendar()[1])
	month = thedate.strftime("%b").lower()
	year = str(thedate.strftime("%Y"))
	date = {'week':week, 'month':month_display(month), 'year':year}
	todaymonth = int(month_number(month))
	todayyear = int(thedate.strftime("%Y"))
	todaymonth = todaymonth - 1
	if todaymonth == 0:
		todaymonth = 12
		todayyear = todayyear-1
	todayreadmonth = number_month(todaymonth)

	today = [todayyear, todaymonth, todayreadmonth]

	stats = Dstats.objects.filter(team=team.id).filter(isoyear=year)

	appstable = []
	for staff in agent:
		qapps = QualifiedApps.objects.filter(year=year).filter(agent=staff).filter(month=month).aggregate(Sum('qualifiedapps'))
		appstable.append([staff.name, qapps['qualifiedapps__sum']])

	weektodate = stats.filter(isoweek=week).aggregate(Sum('totalapps'), Sum('calltime'), Sum('callattempts'), Sum('prodhours'), Sum('sickhours'))
	monthtodate = stats.filter(month=month).aggregate(Sum('totalapps'), Sum('calltime'), Sum('callattempts'), Sum('prodhours'), Sum('sickhours'))
	yeartodate = stats.aggregate(Sum('totalapps'), Sum('calltime'), Sum('callattempts'), Sum('prodhours'), Sum('sickhours'))

	weekfte = {}
	monthfte = {}
	yearfte = {}

	if yeartodate['prodhours__sum'] > 0:
		yearfte['calltime'] = int(yeartodate['calltime__sum'] / (yeartodate['prodhours__sum'] / targets.hours))
		yearfte['totalcalltime'] = yeartodate['calltime__sum']
		yearfte['callattempts'] = int(yeartodate['callattempts__sum'] / (yeartodate['prodhours__sum'] / targets.hours))
		yearfte['totalcallattempts'] = yeartodate['callattempts__sum']
		yearfte['totalapps'] = yeartodate['totalapps__sum']
		yearfte['fteapps'] = yeartodate['totalapps__sum'] / ((yeartodate['prodhours__sum']+yeartodate['sickhours__sum']) / targets.hours)
	if monthtodate['prodhours__sum'] > 0:
		monthfte['calltime'] = int(monthtodate['calltime__sum'] / (monthtodate['prodhours__sum'] / targets.hours))
		monthfte['totalcalltime'] = monthtodate['calltime__sum']
		monthfte['callattempts'] = int(monthtodate['callattempts__sum'] / (monthtodate['prodhours__sum'] / targets.hours))
		monthfte['totalcallattempts'] = monthtodate['callattempts__sum']
		monthfte['totalapps'] = monthtodate['totalapps__sum']
		monthfte['fteapps'] = monthtodate['totalapps__sum'] / ((monthtodate['prodhours__sum']+monthtodate['sickhours__sum']) / targets.hours)
	if weektodate['prodhours__sum'] > 0:
		weekfte['calltime'] = int(weektodate['calltime__sum'] / (weektodate['prodhours__sum'] / targets.hours))
		weekfte['totalcalltime'] = weektodate['calltime__sum']
		weekfte['callattempts'] = int(weektodate['callattempts__sum'] / (weektodate['prodhours__sum'] / targets.hours))
		weekfte['totalcallattempts'] = weektodate['callattempts__sum']
		weekfte['totalapps'] = weektodate['totalapps__sum']
		weekfte['fteapps'] = weektodate['totalapps__sum'] / ((weektodate['prodhours__sum']+weektodate['sickhours__sum']) / targets.hours)

	agentweek = OrderedDict()
	agentmonth = OrderedDict()
	agentyear = OrderedDict()
	agentavgvol = OrderedDict()

	for each in agent:
		volmonth = thedate.strftime("%b").lower()
		yearstats = []
		monthstats = []
		weekstats = []
		volume = []

		volsum = WeeklyStats.objects.filter(agent=each).filter(isomonth=today[2]).filter(isoyear=today[0]).aggregate(Sum('volume'))
		if volsum['volume__sum'] is None:
			volsum = 0
		else:
			volsum = int(volsum['volume__sum'])
		if not volsum > 0:
			volsum = 0

		startdate = each.startdate
		volmonth = startdate.strftime("%b").lower()
		volmonth = int(month_number(volmonth))
		year = int(startdate.strftime("%Y"))

		starting = [year, volmonth]

		diff = (today[0] - starting[0])*12 + (today[1]-starting[1])
		diff = diff - 3

		if diff > 0 :
			volavg = int(volsum) / diff
		else: 
			volavg = int(volsum)

		agentavgvol[each.name] = volavg

		weektodate = stats.filter(agent=each).filter(isoweek=week).aggregate(Sum('totalapps'), Sum('calltime'), Sum('callattempts'), Sum('prodhours'), Sum('sickhours'))
		monthtodate = stats.filter(agent=each).filter(month=month).aggregate(Sum('totalapps'), Sum('calltime'), Sum('callattempts'), Sum('prodhours'), Sum('sickhours'))
		yeartodate = stats.filter(agent=each).aggregate(Sum('totalapps'), Sum('calltime'), Sum('callattempts'), Sum('prodhours'), Sum('sickhours'))

		if yeartodate['prodhours__sum'] > 0:
			yearstats.append(int(yeartodate['calltime__sum'] / (yeartodate['prodhours__sum'] / targets.hours)))
			yearstats.append(yeartodate['calltime__sum'])
			yearstats.append(int(yeartodate['callattempts__sum'] / (yeartodate['prodhours__sum'] / targets.hours)))
			yearstats.append(yeartodate['callattempts__sum'])
			yearstats.append(yeartodate['totalapps__sum'])
			yearstats.append(yeartodate['totalapps__sum'] / ((yeartodate['prodhours__sum']+yeartodate['sickhours__sum']) / targets.hours))
		if monthtodate['prodhours__sum'] > 0:
			monthstats.append(int(monthtodate['calltime__sum'] / (monthtodate['prodhours__sum'] / targets.hours)))
			monthstats.append(monthtodate['calltime__sum'])
			monthstats.append(int(monthtodate['callattempts__sum'] / (monthtodate['prodhours__sum'] / targets.hours)))
			monthstats.append(monthtodate['callattempts__sum'])
			monthstats.append(monthtodate['totalapps__sum'])
			monthstats.append(monthtodate['totalapps__sum'] / ((monthtodate['prodhours__sum']+monthtodate['sickhours__sum']) / targets.hours))
		if weektodate['prodhours__sum'] > 0:
			weekstats.append(int(weektodate['calltime__sum'] / (weektodate['prodhours__sum'] / targets.hours)))
			weekstats.append(weektodate['calltime__sum'])
			weekstats.append(int(weektodate['callattempts__sum'] / (weektodate['prodhours__sum'] / targets.hours)))
			weekstats.append(weektodate['callattempts__sum'])
			weekstats.append(weektodate['totalapps__sum'])
		if weektodate['totalapps__sum'] > 0 and (weektodate['prodhours__sum']+weektodate['sickhours__sum']) > 0:
			weekstats.append(weektodate['totalapps__sum'] / ((weektodate['prodhours__sum']+weektodate['sickhours__sum']) / targets.hours))

		agentweek[each.name] = weekstats
		agentmonth[each.name] = monthstats
		agentyear[each.name] = yearstats

	template = 'team/page.html'
	context = RequestContext(request, {'monthtodate':monthtodate, 'agentavgvol':agentavgvol, 'appstable':appstable, 'agentyear':agentyear, 'agentmonth':agentmonth, 'agentweek':agentweek, 'date':date, 'team':team, 'agent':agent, 'super':super, 'yearfte':yearfte, 'monthfte':monthfte, 'weekfte':weekfte})
    
	response = render_to_response(template, context)
    
	return response
Exemple #13
0
def agent_month_review(request, agent, year, month): #done
    user = request.user.get_profile()
    type = int(user.agenttype)
    agent = get_object_or_404(Agent, slug=agent)
    if not request.user.has_perm('agents.super'):
        if not user.name == agent.name:
            slug = user.slug
            url = "/agent/" + slug
            return HttpResponseRedirect(url) 

    response = HttpResponse(mimetype='application/pdf')
    filename = "%s-AgentMonthReport-%s-%s.pdf" % (agent.slug, month, year)
    response['Content-Disposition'] = 'attachment; filename='+filename

    team = Teams.objects.get(name=agent.teamid)
    target = Targets.objects.get(name=team.targets)
    globalstats = Dstats.objects.filter(agent=agent).filter(isoyear=year).filter(month=month)
    sick = globalstats.filter(sickhours__gt = 0).count()
    working = globalstats.filter(prodhours__gt = 0).count()
    holiday = globalstats.filter(holhours__gt = 0).count()
    monthtotals = globalstats.aggregate(Sum('prodhours'), Sum('totalapps'), Sum('calltime'), Sum('callattempts'), Sum('sickhours'))
    if monthtotals['calltime__sum'] > 0:
        calltime = monthtotals['calltime__sum'] / (monthtotals['prodhours__sum'] / target.hours)
        calltime = int(calltime)
        realcalltime = humantime(calltime)

    qappsum = QualifiedApps.objects.filter(agent=agent).filter(month=month).filter(year=year).aggregate(Sum('qualifiedapps'),)
    qappsum = qappsum['qualifiedapps__sum']
    qapptarget = (target.commission3 / target.days) * agent.parttimedays

    volsum = WeeklyStats.objects.filter(agent=agent).filter(isomonth=month).filter(isoyear=year).aggregate(Sum('volume'), Avg('drawcust'))

    targetct = humantime(target.calltime)
    targetapps = int(((monthtotals['prodhours__sum'] + monthtotals['sickhours__sum']) / target.hours) * Decimal(target.applications))
    targetbuying = str(target.drawingcust) + "%"

    p = canvas.Canvas(response)

    p.setFont("Helvetica", 16)
    titlestring = agent.name + " - Monthly Report: " + month_display(month) + "/" + year
    p.drawString(50,800, titlestring)

    p.setFont("Helvetica-Bold", 16)
    p.drawString(50, 820, team.name)

    p.setFont("Helvetica", 14)

    workingtext = "Working Days: " + str(working)
    sicktext = "Sick Days: " + str(sick)
    holidaytext = "Holiday Days: " + str(holiday)
    p.drawString(50, 770, workingtext)

    p.drawString(450, 770, holidaytext)

    p.drawString(50, 750, "Academy Position: ")

    p.drawString(250, 770, sicktext)

    p.drawString(250, 750, "Academy Year to Date: ")

    p.setFont("Helvetica-Bold", 14)
    p.drawString(50, 720, "MONTHLY")
    p.rect(50,710,500,-125,fill=0)
    
    p.drawString(50, 560, "Review of last months objectives")
    p.rect(50,540,500,-125,fill=0)

    p.drawString(50, 400, "Team and Environment")
    p.rect(50,390,500,-80,fill=0)

    p.drawString(50, 290, "Action Plan")
    p.rect(50,280,500,-140,fill=0)

    p.drawString(50, 120, "Calls")
    p.rect(50,110,500,-50,fill=0)

    p.line(50,685,550,685)
    p.line(50,665,550,665)
    p.line(50,645,550,645)
    p.line(50,625,550,625)
    p.line(50,605,550,605)

    p.line(150,710,150,585)
    p.line(200,710,200,585)
    p.line(250,710,250,585)
    p.line(300,710,300,585)
    p.line(350,710,350,585)

    p.line(295,110,295,60)

    p.setFont("Helvetica", 8)
    p.drawString(155, 700, "Target")
    p.drawString(205, 700, "Actual")
    p.drawString(205, 690, "Month")
    p.drawString(255, 700, "Previous")
    p.drawString(255, 690, "Month")
    p.drawString(305, 700, "Target")
    p.drawString(305, 690, "Met?")
    p.drawString(355, 700, "Comments")

    p.drawString(55, 670, "Average Daily Call Time")
    p.drawString(155, 670, targetct)
    p.drawString(205, 670, realcalltime)
    if calltime >= target.calltime:
        p.drawString(305, 670, "Yes")
    else:
        p.drawString(305, 670, "No")

    p.drawString(55, 650, "New Applications")
    p.drawString(155, 650, str(targetapps))
    p.drawString(205, 650, str(monthtotals['totalapps__sum']))

    if monthtotals['totalapps__sum'] >= targetapps:
        p.drawString(305, 650, "Yes")
    else:
        p.drawString(305, 650, "No")

    p.drawString(55, 630, "Qualified Applications")
    p.drawString(155, 630, str(qapptarget))
    p.drawString(205, 630, str(qappsum))

    if qappsum >= qapptarget:
        p.drawString(305, 630, "Yes")
    else:
        p.drawString(305, 630, "No")

    p.drawString(55, 610, "Monthly Volume")
    p.drawString(155, 610, "")
    p.drawString(205, 610, str(volsum['volume__sum']))

    p.drawString(55, 590, "Buying Customers")
    p.drawString(155, 590, str(targetbuying))
    p.drawString(205, 590, str(volsum['drawcust__avg']))

    p.setFont("Helvetica", 8)
    p.drawString(50, 545, "Please rate your performance:")

    p.setFont("Helvetica", 10)
    p.drawString(170, 545, "Excellent -")
    p.rect(220,545,10,10,fill=0)

    p.drawString(235, 545, "Very Good -")
    p.rect(293,545,10,10,fill=0)

    p.drawString(308, 545, "Good -")
    p.rect(343,545,10,10,fill=0)

    p.drawString(358, 545, "Average -")
    p.rect(405,545,10,10,fill=0)

    p.drawString(420, 545, "Below average -")
    p.rect(495,545,10,10,fill=0)

    p.drawString(510, 545, "Poor -")
    p.rect(540,545,10,10,fill=0)

    p.setFont("Helvetica", 8)
    p.drawString(55, 530, "What went well for you last month?")
    p.drawString(55, 500, "What could you have improved on?")
    p.drawString(55, 470, "How do you feel your performance compares to last month?")
    p.drawString(55, 440, "Would you like any additional training to improve your performance?")

    p.drawString(55, 380, "Do you have any suggestions for improving either the office environment or working procedures?")
    p.drawString(55, 345, "Is there anything else you would like to discuss?")

    p.drawString(55, 270, "Objectives and Goals for next month:")
    p.drawString(55, 220, "How do you intend to achieve this?")
    p.drawString(55, 170, "Additional Comments:")

    p.drawString(450, 270, "FU Date:")
    p.drawString(450, 220, "FU Date:")
    p.drawString(450, 170, "FU Date:")

    p.drawString(55, 100, "Two things to Continue")
    p.drawString(300, 100, "Two things to implement")

    p.drawString(50, 35, "Signed(Agent)")
    p.line(150,34,400,34)
    p.drawString(50, 15, "Signed(Supervisor)")
    p.line(150,14,400,14)

    p.drawString(450, 35, "Date:")
    p.line(480,34,550,34)
    p.drawString(450, 15, "Date")
    p.line(480,14,550,14)

    p.showPage()
    p.save()

    return response
    
Exemple #14
0
def stats_day(request, year, month, day): #done
	stat = daily_stats(year, month, day)

	date = '/'.join([day, month_display(month), year])
	title = "Agent Stats: " + date
	switchtype = "Team"

	highcalls = []
	highattempts = []
	highapps = []

	targets = Targets.objects.get(pk=1)

	highest = 0
	highest2 = 0
	highest3 = 0
	highcall = stat.order_by('-calltime')
	for Dstat in highcall:
		if Dstat.calltime >= highest:
			highest = Dstat.calltime
			highcalls.append([Dstat.agent, Dstat.calltime])
		elif Dstat.calltime >= highest2:
			highest2 = Dstat.calltime
			highcalls.append([Dstat.agent, Dstat.calltime])
		elif Dstat.calltime >= highest3:
			highest3 = Dstat.calltime
			highcalls.append([Dstat.agent, Dstat.calltime])
	        
	        
	highest = 0
	highest2 = 0
	highest3 = 0
	highattempt = stat.order_by('-callattempts')
	for Dstat in highattempt:
	    if Dstat.callattempts >= highest:
	        highest = Dstat.callattempts
	        highattempts.append([Dstat.agent, Dstat.callattempts])
	    elif Dstat.callattempts >= highest2:
	        highest2 = Dstat.callattempts
	        highattempts.append([Dstat.agent, Dstat.callattempts])
	    elif Dstat.callattempts >= highest3:
	        highest3 = Dstat.callattempts
	        highattempts.append([Dstat.agent, Dstat.callattempts])
	        
	highest = 0
	highest2 = 0
	highest3 = 0
	highapp = stat.order_by('-totalapps')
	for Dstat in highapp:
	    if Dstat.totalapps >= highest:
	        highest = Dstat.totalapps
	        highapps.append([Dstat.agent, Dstat.totalapps])
	    elif Dstat.totalapps >= highest2:
	        highest2 = Dstat.totalapps
	        highapps.append([Dstat.agent, Dstat.totalapps])
	    elif Dstat.totalapps >= highest3:
	        highest3 = Dstat.totalapps
	        highapps.append([Dstat.agent, Dstat.totalapps])

	switch = "/stats/team/"+year+"/"+month+"/"+day
	printdate = "/stats/"+year+"/"+month+"/"+day+"/print"
	switchtype = "Team"

	template = 'stats/daily.html'
	context = RequestContext(request, {'print':printdate, 'switch':switch, 'targets':targets, 'highapps':highapps, 'highattempts':highattempts, 'highcall':highcalls, 'title':title, 'stat':stat, 'switchtype':switchtype})

	response = render_to_response(template, context)

	return response
Exemple #15
0
def stats_today(request): #done
	thedate = datetime.today()-timedelta(days=1)
	if thedate.isoweekday() == 7:
		thedate = datetime.today()-timedelta(days=3)

	day = str(thedate.strftime("%d"))
	month = thedate.strftime("%b").lower()
	year = str(thedate.strftime("%Y"))
		
	stat = daily_stats(year, month, day)

	date = '/'.join([day, month_display(thedate.strftime("%b").lower()), year])
	title = "Agent Stats: " + date
	switchtype = "Team"

	highcalls = []
	highattempts = []
	highapps = []

	targets = Targets.objects.get(pk=1)

	highest = 0
	highest2 = 0
	highest3 = 0
	highcall = stat.order_by('-calltime')
	for Dstat in highcall:
		if Dstat.calltime >= highest:
			highest = Dstat.calltime
			highcalls.append([Dstat.agent, Dstat.calltime])
		elif Dstat.calltime >= highest2:
			highest2 = Dstat.calltime
			highcalls.append([Dstat.agent, Dstat.calltime])
		elif Dstat.calltime >= highest3:
			highest3 = Dstat.calltime
			highcalls.append([Dstat.agent, Dstat.calltime])
	        
	        
	highest = 0
	highest2 = 0
	highest3 = 0
	highattempt = stat.order_by('-callattempts')
	for Dstat in highattempt:
	    if Dstat.callattempts >= highest:
	        highest = Dstat.callattempts
	        highattempts.append([Dstat.agent, Dstat.callattempts])
	    elif Dstat.callattempts >= highest2:
	        highest2 = Dstat.callattempts
	        highattempts.append([Dstat.agent, Dstat.callattempts])
	    elif Dstat.callattempts >= highest3:
	        highest3 = Dstat.callattempts
	        highattempts.append([Dstat.agent, Dstat.callattempts])
	        
	highest = 0
	highest2 = 0
	highest3 = 0
	highapp = stat.order_by('-totalapps')
	for Dstat in highapp:
	    if Dstat.totalapps >= highest:
	        highest = Dstat.totalapps
	        highapps.append([Dstat.agent, Dstat.totalapps])
	    elif Dstat.totalapps >= highest2:
	        highest2 = Dstat.totalapps
	        highapps.append([Dstat.agent, Dstat.totalapps])
	    elif Dstat.totalapps >= highest3:
	        highest3 = Dstat.totalapps
	        highapps.append([Dstat.agent, Dstat.totalapps])


	switch = "/stats/team/"+str(year)+"/"+month+"/"+day
	printdate = "/stats/"+year+"/"+month+"/"+day+"/print"

	template = 'stats/daily.html'
	context = RequestContext(request, {'print':printdate, 'switch':switch, 'targets':targets, 'highapps':highapps, 'highattempts':highattempts, 'highcall':highcalls, 'title':title, 'stat':stat, 'switchtype':switchtype})

	response = render_to_response(template, context)

	return response
Exemple #16
0
def agent_page(request, agent): #done
    user = request.user.get_profile()
    type = int(user.agenttype)
    agent = get_object_or_404(Agent, slug=agent)
    if not request.user.has_perm('agents.super'):
        if not user.name == agent.name:
            slug = user.slug
            url = "/agent/" + slug
            return HttpResponseRedirect(url) 
    
    globalstats = Dstats.objects.filter(agent=agent)

    if agent.haveleft == 0:
        team = Teams.objects.get(name=agent.teamid)
        targets = Targets.objects.get(name=team.targets)
    else:
        targets = Targets.objects.get(pk=1)

    ill = globalstats.filter(sickhours__gt = 0).order_by('-date')[:10]
    hol = globalstats.filter(holhours__gt = 0).order_by('-date')[:10]
    acheive = Incentive.objects.filter(agent=agent.id)[:20]
    candc = CoachingAndCompliance.objects.filter(agent=agent.id).order_by('-date')[:20]
    training = Training.objects.filter(agent=agent.id).order_by('-date')[:50]

    thedate = datetime.today()
    isoweek = int(thedate.isocalendar()[1])
    isoyear = thedate.isocalendar()[0]
    month = thedate.strftime("%b").lower()

    totals = globalstats.filter(isoyear=isoyear).aggregate(Sum('callattempts'), Sum('calltime'), Sum('prodhours'), Sum('sickhours'), Sum('totalapps'))
    monthtotals = globalstats.filter(isoyear=isoyear).filter(month=month).aggregate(Sum('callattempts'), Sum('calltime'), Sum('prodhours'), Sum('sickhours'), Sum('totalapps'))
    
    """
    This section works out a series of FTE requirements
    """

    fte = {}
    fte["calltime"] = 0
    if totals['calltime__sum'] > 0:
        fte["calltime"] = totals['calltime__sum'] / (totals['prodhours__sum'] / targets.hours)
    if fte["calltime"] > 0:
        fte["calltime"] = int(fte["calltime"])

    fte["callattempts"] = 0
    if totals['callattempts__sum'] > 0:
        fte["callattempts"] = totals['callattempts__sum'] / (totals['prodhours__sum'] / targets.hours)
    if fte["callattempts"] > 0:
        fte["callattempts"] = int(fte["callattempts"])

    fte["totalapps"] = 0
    if totals['totalapps__sum'] > 0:
        fte["totalapps"] = totals['totalapps__sum'] / ((totals['prodhours__sum'] + totals['sickhours__sum']) / targets.hours)
    if fte["totalapps"] > 0:
        fte["totalapps"] = fte["totalapps"]

    monthfte = {}
    monthfte["calltime"] = 0
    if monthtotals['calltime__sum'] > 0:
        monthfte["calltime"] = monthtotals['calltime__sum'] / (monthtotals['prodhours__sum'] / targets.hours)
    if monthfte["calltime"] > 0:
        monthfte["calltime"] = int(monthfte["calltime"])

    monthfte["callattempts"] = 0
    if monthtotals['callattempts__sum'] > 0:
        monthfte["callattempts"] = monthtotals['callattempts__sum'] / (monthtotals['prodhours__sum'] / targets.hours)
    if monthfte["callattempts"] > 0:
        monthfte["callattempts"] = int(monthfte["callattempts"])

    monthfte["totalapps"] = 0
    if monthtotals['totalapps__sum'] > 0:
        monthfte["totalapps"] = monthtotals['totalapps__sum'] / ((monthtotals['prodhours__sum'] + monthtotals['sickhours__sum']) / targets.hours)
    if monthfte["totalapps"] > 0:
        monthfte["totalapps"] = monthfte["totalapps"]

    quartertotals = globalstats.filter(isoyear=isoyear).exclude(month='jan').exclude(month='feb').exclude(month='mar').exclude(month='jul').exclude(month='aug').exclude(month='sep').exclude(month='oct').exclude(month='nov').exclude(month='dec').aggregate(Sum('callattempts'), Sum('calltime'), Sum('prodhours'), Sum('sickhours'), Sum('totalapps'))
    quarterfte = {}
    quarterfte["calltime"] = 0
    if quartertotals['calltime__sum'] > 0:
        quarterfte["calltime"] = quartertotals['calltime__sum'] / (quartertotals['prodhours__sum'] / targets.hours)
    if quarterfte["calltime"] > 0:
        quarterfte["calltime"] = int(quarterfte["calltime"])

    quarterfte["callattempts"] = 0
    if quartertotals['callattempts__sum'] > 0:
        quarterfte["callattempts"] = quartertotals['callattempts__sum'] / (quartertotals['prodhours__sum'] / targets.hours)
    if quarterfte["callattempts"] > 0:
        quarterfte["callattempts"] = int(quarterfte["callattempts"])

    quarterfte["totalapps"] = 0
    if quartertotals['totalapps__sum'] > 0:
        quarterfte["totalapps"] = quartertotals['totalapps__sum'] / ((quartertotals['prodhours__sum'] + quartertotals['sickhours__sum']) / targets.hours)
    if quarterfte["totalapps"] > 0:
        quarterfte["totalapps"] = quarterfte["totalapps"]

    """
    This section gets the stats for the charts on the page, organising by week from the start of the year.
    """
    chartstats = Dstats.objects.filter(agent=agent)
    chartweeks = []
    calltime = []
    callattempts = []
    apps = []
    weeks = OrderedDict()
    weekdata = []
    if isoweek > 1 :    
        startweek = 1 
        while startweek < isoweek:
            statsum = chartstats.filter(isoyear=isoyear).filter(isoweek=startweek).aggregate(Sum('totalapps'), Sum('callattempts'), Sum('calltime'), Sum('prodhours'), Sum('sickhours'))
            if statsum['prodhours__sum'] > 0:
                calltimeavg = statsum['calltime__sum'] / (statsum['prodhours__sum'] / targets.hours)
                callattemptsavg = statsum['callattempts__sum'] / (statsum['prodhours__sum'] / targets.hours)
                appsavg = statsum['totalapps__sum'] / ((statsum['prodhours__sum']+statsum['sickhours__sum']) / targets.hours)
                calltime.append(int(calltimeavg))
                callattempts.append(int(callattemptsavg))
                apps.append(statsum['totalapps__sum'] )
                chartweeks.append(startweek)
                weeks[startweek] = weekdata
                weekdata = []
                statsum = []
            else:
                calltime.append(0)
                callattempts.append(0)
                apps.append(0)
                chartweeks.append(startweek)
                weekdata.append([0, 0, 0])
                weeks[startweek] = weekdata
                weekdata = []
                statsum = []
            startweek = startweek + 1

    """
    Same as the above except for the volume and qualified apps charts
    """
    months = OrderedDict()
    months['jan'] = 'January'
    months['feb'] = 'February'
    months['mar'] = 'March'
    months['apr'] = 'April'
    months['may'] = 'May'
    months['jun'] = 'June'
    months['jul'] = 'July'
    months['aug'] = 'August'
    months['sep'] = 'September'
    months['oct'] = 'October'
    months['nov'] = 'November'
    months['dec'] = 'December'
    
    qappweeks = OrderedDict()
    volweeks = OrderedDict()
    
    for key,value in months.iteritems():
        qappsum = QualifiedApps.objects.filter(agent=agent).filter(month=key).filter(year=isoyear).aggregate(Sum('qualifiedapps'),)
        volsum = WeeklyStats.objects.filter(agent=agent).filter(isomonth=key).filter(isoyear=isoyear).aggregate(Sum('volume'),)

        qappsum = qappsum['qualifiedapps__sum']
        volsum = volsum['volume__sum']

        if not qappsum >= 0:
            qappsum = 0

        if not volsum >= 0:
            volsum = 0

        qappweeks[value] = qappsum
        volweeks[value] = volsum
        volsum = 0
        qappsum = 0

    template = 'agents/page.html'
    context = RequestContext(request, {'quartertotals':quartertotals, 'quarterfte':quarterfte,'candc':candc, 'vol':volweeks, 'qapps':qappweeks, 'apps':apps,'callattempts':callattempts,'calltime':calltime,'weeks':chartweeks, 'agent':agent, 'sick':ill, 'hol':hol, 'training':training,'acheive':acheive, 'totals':totals, 'fte':fte, 'monthtotals':monthtotals, 'monthfte':monthfte, 'month':month_display(month)})
    
    response = render_to_response(template, context)
    
    return response
Exemple #17
0
def saul_dashboard(request): 
    if not request.user.has_perm('agents.saul'):
        url = "/"
        return HttpResponseRedirect(url)

    thedate = datetime.today() #gets today's date
    isoweek = thedate.isocalendar()[1] #get today's isoweek
    isoyear = thedate.strftime("%Y") #gets this year

    dstatquery = Dstats.objects.filter(isoyear=isoyear) #the base query to get all the objects in that year
    qappquery = QualifiedApps.objects.filter(year=isoyear) #the base query to get all the objects in that year
    wstatquery = WeeklyStats.objects.filter(isoyear=isoyear) #the base query to get all the objects in that year

    team_list = Teams.objects.filter(teamtype=1) #list of all the teams to display on the charts

    calltimeweeks = OrderedDict() #dict of each weeks containing calltime averages
    callattemptsweeks = OrderedDict() #dict of each week containing call attempt averages

    totalapplicationweeks = OrderedDict() #dict containing total applications by week
    fteapplicationweeks = OrderedDict() #dict containing fte applications by week

    otherhourweeks = OrderedDict() #hours in graph form by week
    sickhourweeks = OrderedDict() #hours in graph form by week
    holidayhourweeks = OrderedDict() #hours in graph form by week

    qualifiedappmonths = OrderedDict() #dict containing monthly qualifed apps

    teamcalls = OrderedDict()
    teamattempts = OrderedDict()
    teamapps = OrderedDict()
    teamfte = OrderedDict()
    teamqa = OrderedDict()
    teamvol = OrderedDict()

    volumemonths =OrderedDict() #dict containing monthly volume totals

    if isoweek > 1:
        startweek = 1
        while startweek < isoweek:
            targets = Targets.objects.get(pk=1)
            teamstats = dstatquery.filter(isoweek=startweek).filter(team__teamtype=1).aggregate(Sum('totalapps'), Sum('callattempts'), Sum('calltime'), Sum('prodhours'), Sum('sickhours'), Sum('holhours'), Sum('otherhours'))
            if teamstats['prodhours__sum'] > 0:
                calltimeavg = int(teamstats['calltime__sum'] / (teamstats['prodhours__sum'] / targets.hours))
                callattemptsavg = teamstats['callattempts__sum'] / (teamstats['prodhours__sum'] / targets.hours)
                appsavg = teamstats['totalapps__sum'] / ((teamstats['prodhours__sum'] + teamstats['sickhours__sum']) / targets.hours)
            else:
                calltimeavg = 0
                callattemptsavg = 0
                appsavg = 0
            teamcalls[startweek] = calltimeavg
            teamattempts[startweek] = callattemptsavg
            teamapps[startweek] = teamstats['totalapps__sum']
            teamfte[startweek] = appsavg
            startweek += 1

    if isoweek > 1 :
        startweek = 1
        while startweek < isoweek:
            ctlist = []
            calist = []
            apps = []
            sick = []
            hol = []
            other = []
            tapps = []
            vol = []
            for teams in team_list:
                targets = Targets.objects.get(name=teams.targets)
                stats = dstatquery.filter(isoweek=startweek).filter(team=teams).aggregate(Sum('totalapps'), Sum('callattempts'), Sum('calltime'), Sum('prodhours'), Sum('sickhours'), Sum('holhours'), Sum('otherhours'))
                if stats['prodhours__sum'] > 0:
                    calltimeavg = stats['calltime__sum'] / (stats['prodhours__sum'] / targets.hours)
                    callattemptsavg = stats['callattempts__sum'] / (stats['prodhours__sum'] / targets.hours)
                    appsavg = stats['totalapps__sum'] / ((stats['prodhours__sum'] + stats['sickhours__sum']) / targets.hours)
                else:
                    calltimeavg = 0
                    callattemptsavg = 0
                    appsavg = 0

                ctlist.append(calltimeavg)
                calist.append(callattemptsavg)
                apps.append(appsavg)
                sick.append(stats['sickhours__sum'])
                hol.append(stats['holhours__sum'])
                other.append(stats['otherhours__sum'])
                tapps.append(stats['totalapps__sum'])

                agents = Agent.objects.filter(teamid=teams).filter(haveleft=0)

                totalvolume = 0
                for agent in agents:
                    volsum = wstatquery.filter(agent=agent).filter(isoweek=startweek).aggregate(Sum('volume'),)
                    volsum = volsum['volume__sum']
                    if not volsum >= 0:
                        volsum = 0
                    totalvolume += volsum
        
                vol.append(totalvolume)
            volumemonths[startweek] = vol

            calltimeweeks[startweek] = ctlist
            callattemptsweeks[startweek] = calist
            fteapplicationweeks[startweek] = apps
            totalapplicationweeks[startweek] = tapps
            sickhourweeks[startweek] = sick
            holidayhourweeks[startweek] = hol
            otherhourweeks[startweek] = other
            
            startweek += 1

    months = month_list()
    for month in months:
        qapps = []
        #vol = []
        for teams in team_list:
            agents = Agent.objects.filter(teamid=teams).filter(haveleft=0)
            totalapps = 0
            #totalvolume = 0
            for agent in agents:
                qappsum = qappquery.filter(agent=agent).filter(month=month).aggregate(Sum('qualifiedapps'),)
                #volsum = wstatquery.filter(agent=agent).filter(isomonth=month).aggregate(Sum('volume'),)
                qappsum = qappsum['qualifiedapps__sum']
                #volsum = volsum['volume__sum']
                if not qappsum >= 0:
                    qappsum = 0
                #if not volsum >= 0:
                #    volsum = 0
                totalapps += qappsum
                #totalvolume += volsum
            qapps.append(totalapps)
            #vol.append(totalvolume)
        qualifiedappmonths[month_display(month)] = qapps
        #volumemonths[month_display(month)] = vol

    cumqualmonths = OrderedDict()
    for month in month_list():
        qappsum = qappquery.filter(agent__teamid__teamtype=1).filter(month=month).aggregate(Sum('qualifiedapps'),)
        cumqualmonths[month_display(month)] = qappsum['qualifiedapps__sum']

    chart_list = Teams.objects.filter(teamtype=5)
    thedate = datetime.today()
    isoweek = thedate.isocalendar()[1]
    isoyear = thedate.isocalendar()[0]

    chartweeks = []

    ctweeks = OrderedDict()
    caweeks = OrderedDict()
    appweeks = OrderedDict()

    ctlist = []
    calist = []
    apps = []

    if isoweek > 1 :    
        startweek = 1 
        while startweek < isoweek:
            for teams in chart_list:
                targets = Targets.objects.get(name=teams.targets)
                statsum = Dstats.objects.filter(isoyear=isoyear).filter(isoweek=startweek).filter(team=teams).aggregate(Sum('totalapps'), Sum('callattempts'), Sum('calltime'), Sum('prodhours'), Sum('sickhours'))
                if statsum['prodhours__sum'] > 0:
                    calltimeavg = statsum['calltime__sum'] / (statsum['prodhours__sum'] / targets.hours)
                    callattemptsavg = statsum['callattempts__sum'] / (statsum['prodhours__sum'] / targets.hours)
                    appsavg = statsum['totalapps__sum']
                else:
                    calltimeavg = 0
                    callattemptsavg = 0
                    appsavg = 0

                ctlist.append(calltimeavg)
                calist.append(callattemptsavg)
                apps.append(appsavg)
                
            ctweeks[startweek] = ctlist
            caweeks[startweek] = calist
            appweeks[startweek] = apps
            ctlist = []
            calist = []
            apps = []
            statsum = []
            startweek = startweek + 1

    template = 'core/saul.html'
    context = RequestContext(request, {
        'teamlist':team_list,
        'calltimeweeks':calltimeweeks,
        'callattemptsweeks':callattemptsweeks,
        'totalapplicationweeks':totalapplicationweeks,
        'fteapplicationweeks':fteapplicationweeks,
        'otherhourweeks':otherhourweeks,
        'sickhourweeks':sickhourweeks,
        'holidayhourweeks':holidayhourweeks,
        'qualifiedappmonths':qualifiedappmonths,
        'volumemonths':volumemonths,
        'teamcalls': teamcalls,
        'teamattempts': teamattempts,
        'teamapps': teamapps,
        'teamfte': teamfte,
        'cumqualmonths': cumqualmonths,
        'year':isoyear,
        'catable':caweeks, 'cttable':ctweeks, 'appstable':appweeks, 'chart_list':chart_list
        })

    response = render_to_response(template, context)

    return response