def generate_payslip(request): user_profile = UserProfile.objects.get(user=request.user) response = HttpResponse(content_type='application/pdf') response['Content-Disposition'] = 'attachment; filename="payslip.pdf"' payslip = get_payslip(user_profile) response.write(payslip) return response
def send_payslips(self, request, queryset): subject = "Payslip for the month of {0}".format( timezone.now().strftime("%B")) message = """ Dear {0} {1}, Please find the payslip for the month of {2} attached to this mail. Thank You, Agiliq Team """.format(request.user.first_name, request.user.last_name, timezone.now().strftime("%B")) for payroll in queryset: user_profile = payroll.employee.user_profile payslip = get_payslip(user_profile) send_an_email(subject, message, settings.LEAVE_TRACKER_RECIPIENT, [ request.user.email], payslip) self.message_user( request, "Payslips sent to selected employees successfully.")
def send_payslips(self, request, queryset): subject = "Payslip for the month of {0}".format( timezone.now().strftime("%B")) message = """ Dear {0} {1}, Please find the payslip for the month of {2} attached to this mail. Thank You, Agiliq Team """.format(request.user.first_name, request.user.last_name, timezone.now().strftime("%B")) for payroll in queryset: user_profile = payroll.employee.user_profile payslip = get_payslip(user_profile) send_an_email(subject, message, settings.LEAVE_TRACKER_RECIPIENT, [request.user.email], payslip) self.message_user(request, "Payslips sent to selected employees successfully.")