Пример #1
0
def generate_report(request):
	from datetime import date, datetime
	today = date.today()
	start_date = end_date = None
	
	report_type = request.GET.get('type', 'leavereport')
	if report_type == 'leavereport':
		year = request.GET.get('year', today.year)
		month = request.GET.get('month', today.month)
		
		day = request.GET.get('day', settings.LEAVE_REPORT_FIRST_DAY)
		start_date = datetime(int(year), 1, 1)
		end_date = datetime(int(year), int(month), int(day))
		main_utils.generate_reports(report_type, int(year), int(month), int(day))
		
		subject = "Monthly leave report %s" % end_date.strftime('%Y-%m-%d')
		type = 'leave report'
		
	if report_type == 'leaverecord':
		start = request.GET.get('start')
		end = request.GET.get('end')
		
		start_date = datetime.strptime(start, "%Y-%m-%d")
		end_date = datetime.strptime(end + ' 17:30', "%Y-%m-%d %H:%M")
		main_utils.generate_reports(report_type, year = today.year, month = today.month, start_date = start_date, end_date = end_date)
	
		subject = "Monthly leave record report(%s~%s)" % (start_date.strftime('%Y-%m-%d'), end_date.strftime('%Y-%m-%d'))
		type = 'leave record'
		
	from common.utils import send_email_to_admin
	send_email_to_admin('report_notification.txt', subject, end_date, start_date, type)
	
	return redirect('/eleave/main/reports/')
Пример #2
0
def GenerateLeaveRecordsReport():
	now = datetime.now()
	start_date = report.get_lastest_month_period(now)
	employees = Employee.objects.all()

	report.generate_leave_record_report_file(employees, start_date, now)

	# send email to notice admin
	subject = "Monthly leave record report(%s~%s)" % (start_date.strftime('%Y-%m-%d'), now.strftime('%Y-%m-%d'))
	send_email_to_admin('report_notification.txt', subject, now, start_date, type = 'leave record')
Пример #3
0
def GenerateLeavesReport():
    now = datetime.now()
    employees = Employee.objects.all()

    # generate leave report file automaticaly,
    # use Windows Task Scheduler to control
    report.generate_leave_report_file(employees, now.day, now.month, now.year)

    # send email to notice admin
    subject = "Monthly leave report %s" % now.strftime("%Y-%m-%d")
    send_email_to_admin("report_notification.txt", subject, now, type="leave report")