diff --git a/frappe/email/doctype/auto_email_report/auto_email_report.py b/frappe/email/doctype/auto_email_report/auto_email_report.py
index 79aeff9713..8903b813dc 100644
--- a/frappe/email/doctype/auto_email_report/auto_email_report.py
+++ b/frappe/email/doctype/auto_email_report/auto_email_report.py
@@ -8,6 +8,7 @@ from frappe import _
from frappe.model.document import Document
from datetime import timedelta
import frappe.utils
+from frappe.utils import now, global_date_format, format_time
from frappe.utils.xlsxutils import make_xlsx
from frappe.utils.csvutils import to_csv
@@ -76,16 +77,28 @@ class AutoEmailReport(Document):
return xlsx_file.getvalue()
elif self.format == 'CSV':
- spreadsheet_data = self.get_spreadsheet_data(columns, data)
+ spreadsheet_data = self.get_spreadsheet_data(columns, data)
return to_csv(spreadsheet_data)
else:
frappe.throw(_('Invalid Output Format'))
- def get_html_table(self, columns, data):
- return frappe.render_template('frappe/templates/includes/print_table.html', {
+ def get_html_table(self, columns=None, data=None):
+
+ date_time = global_date_format(now()) + ' ' + format_time(now())
+ report_doctype = frappe.db.get_value('Report', self.report, 'ref_doctype')
+
+ return frappe.render_template('frappe/templates/emails/auto_email_report.html', {
+ 'title': self.name,
+ 'description': self.description,
+ 'date_time': date_time,
'columns': columns,
- 'data': data
+ 'data': data,
+ 'report_url': frappe.utils.get_url_to_report(self.report,
+ self.report_type, report_doctype),
+ 'report_name': self.report,
+ 'edit_report_settings': frappe.utils.get_link_to_form('Auto Email Report',
+ self.name)
})
@staticmethod
@@ -111,29 +124,17 @@ class AutoEmailReport(Document):
return
attachments = None
- message = '
{0}
'.format(_('{0} generated on {1}')\
- .format(frappe.bold(self.name),
- frappe.utils.format_datetime(frappe.utils.now_datetime())))
-
- if self.description:
- message += '
' + self.description
-
- if self.format=='HTML':
- message += '
' + data
+ if self.format == "HTML":
+ message = data
else:
+ message = self.get_html_table()
+
+ if not self.format=='HTML':
attachments = [{
'fname': self.get_file_name(),
'fcontent': data
}]
- report_doctype = frappe.db.get_value('Report', self.report, 'ref_doctype')
- report_footer = frappe.render_template(self.get_report_footer(),
- dict(report_url = frappe.utils.get_url_to_report(self.report, self.report_type, report_doctype),
- report_name = self.report,
- edit_report_settings = frappe.utils.get_link_to_form('Auto Email Report', self.name)))
-
- message += report_footer
-
frappe.sendmail(
recipients = self.email_to.split(),
subject = self.name,
@@ -141,14 +142,6 @@ class AutoEmailReport(Document):
attachments = attachments
)
- def get_report_footer(self):
- return """
-
- View report in your browser:
- {{report_name}}
- Edit Auto Email Report Settings: {{edit_report_settings}}
-
"""
-
@frappe.whitelist()
def download(name):
'''Download report locally'''
diff --git a/frappe/public/css/email.css b/frappe/public/css/email.css
index 57aeb6cb66..39044a0d1e 100644
--- a/frappe/public/css/email.css
+++ b/frappe/public/css/email.css
@@ -6,9 +6,10 @@ body {
p {
margin: 1em 0 !important;
}
-.body-table,
-.email-body tr,
-.email-footer tr {
+hr {
+ border-top: 1px solid #d1d8dd;
+}
+.body-table {
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen", "Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue", sans-serif;
}
.email-header,
@@ -17,13 +18,11 @@ p {
width: 100% !important;
min-width: 100% !important;
}
-.email-body tr {
+.email-body {
font-size: 14px;
}
.email-footer {
border-top: 1px solid #d1d8dd;
-}
-.email-footer tr {
font-size: 12px;
}
.email-header {
@@ -61,4 +60,64 @@ p {
background-color: #5E64FF;
border-color: #444bff;
}
+.table {
+ width: 100%;
+ border-collapse: collapse;
+}
+.table td,
+.table th {
+ padding: 8px;
+ line-height: 1.42857143;
+ vertical-align: top;
+ border-top: 1px solid #d1d8dd;
+ text-align: left;
+}
+.table th {
+ font-weight: bold;
+}
+.table > thead > tr > th {
+ vertical-align: bottom;
+ border-bottom: 2px solid #d1d8dd;
+}
+.table > thead:first-child > tr:first-child > th {
+ border-top: none;
+}
+.table.table-bordered {
+ border: 1px solid #d1d8dd;
+}
+.table.table-bordered td,
+.table.table-bordered th {
+ border: 1px solid #d1d8dd;
+}
+.more-info {
+ font-size: 80% !important;
+ color: #8D99A6 !important;
+ border-top: 1px solid #EBEFF2;
+ padding-top: 10px;
+}
+.text-right {
+ text-align: right !important;
+}
+.text-center {
+ text-align: center !important;
+}
+.text-muted {
+ color: #8D99A6 !important;
+}
+.text-extra-muted {
+ color: #d1d8dd !important;
+}
+.text-regular {
+ font-size: 14px;
+}
+.text-medium {
+ font-size: 12px;
+}
+.text-small {
+ font-size: 10px;
+}
+/* auto email report */
+.report-title {
+ margin-bottom: 20px;
+}
/* csslint ignore:end */
diff --git a/frappe/public/less/email.less b/frappe/public/less/email.less
index d14cbe4561..e1bfa7ebbe 100644
--- a/frappe/public/less/email.less
+++ b/frappe/public/less/email.less
@@ -10,7 +10,11 @@ p {
margin: 1em 0 !important;
}
-.body-table, .email-body tr, .email-footer tr {
+hr {
+ border-top: 1px solid @border-color;
+}
+
+.body-table {
font-family: @font-stack;
}
@@ -19,16 +23,13 @@ p {
min-width: 100% !important;
}
-.email-body tr {
+.email-body {
font-size: @text-regular;
}
.email-footer {
border-top: 1px solid @border-color;
-
- tr {
- font-size: @text-medium;
- }
+ font-size: @text-medium;
}
.email-header {
@@ -75,4 +76,77 @@ p {
}
}
-/* csslint ignore:end */
\ No newline at end of file
+.table {
+ width: 100%;
+ border-collapse: collapse;
+
+ td, th {
+ padding: 8px;
+ line-height: 1.42857143;
+ vertical-align: top;
+ border-top: 1px solid @border-color;
+ text-align: left;
+ }
+
+ th {
+ font-weight: bold;
+ }
+
+ & > thead > tr > th {
+ vertical-align: bottom;
+ border-bottom: 2px solid @border-color;
+ }
+
+ & > thead:first-child > tr:first-child > th {
+ border-top: none;
+ }
+
+ &.table-bordered {
+ border: 1px solid @border-color;
+
+ td, th {
+ border: 1px solid @border-color;
+ }
+ }
+}
+
+.more-info {
+ font-size: 80% !important;
+ color: @text-muted !important;
+ border-top: 1px solid @light-border-color;
+ padding-top: 10px;
+}
+
+.text-right {
+ text-align: right !important;
+}
+
+.text-center {
+ text-align: center !important;
+}
+
+.text-muted {
+ color: @text-muted !important;
+}
+
+.text-extra-muted {
+ color: @text-extra-muted !important;
+}
+
+.text-regular {
+ font-size: @text-regular;
+}
+
+.text-medium {
+ font-size: @text-medium;
+}
+
+.text-small {
+ font-size: @text-small;
+}
+
+/* auto email report */
+.report-title {
+ margin-bottom: 20px;
+}
+/* csslint ignore:end */
diff --git a/frappe/templates/emails/auto_email_report.html b/frappe/templates/emails/auto_email_report.html
new file mode 100644
index 0000000000..d4bea7c70e
--- /dev/null
+++ b/frappe/templates/emails/auto_email_report.html
@@ -0,0 +1,51 @@
+{% macro get_alignment(col) %}
+{%- if col.fieldtype in ('Int', 'Float', 'Currency', 'Check') %} class="text-right" {% endif -%}
+{% endmacro %}
+
+
+
+
+ {{ title }} {{ date_time }}
+ |
+
+ {% if description %}
+
+ {{ description }} |
+
+ {% endif %}
+
+{% if data %}
+
+
+
+ {% for col in columns %}
+
+ {{- col.label -}}
+ |
+ {% endfor %}
+
+
+
+ {% for row in data %}
+
+ {% for col in columns %}
+
+ {{- frappe.format(row[col.fieldname], col, row) -}}
+ |
+ {% endfor %}
+
+ {% endfor %}
+
+
+{% endif %}
+
+
+
+
+ {{ _("View report in your browser") }}:
+ {{report_name}}
+
+ {{ _("Edit Auto Email Report Settings") }}: {{edit_report_settings}}
+ |
+
+
\ No newline at end of file