diff --git a/frappe/boot.py b/frappe/boot.py
index 415d38a6de..23c52dbc0f 100644
--- a/frappe/boot.py
+++ b/frappe/boot.py
@@ -51,6 +51,7 @@ def get_bootinfo():
load_translations(bootinfo)
add_timezone_info(bootinfo)
load_conf_settings(bootinfo)
+ load_print_css(bootinfo)
# ipinfo
if frappe.session['data'].get('ipinfo'):
@@ -149,3 +150,6 @@ def add_timezone_info(bootinfo):
frappe.utils.momentjs.update(user, bootinfo.timezone_info)
frappe.utils.momentjs.update(system, bootinfo.timezone_info)
+def load_print_css(bootinfo):
+ bootinfo.print_css = frappe.get_attr("frappe.templates.pages.print.get_print_style")(frappe.db.get_single_value("Print Settings",
+ "print_style") or "Modern")
diff --git a/frappe/core/doctype/communication/communication.py b/frappe/core/doctype/communication/communication.py
index 00cc40743e..072e9faef9 100644
--- a/frappe/core/doctype/communication/communication.py
+++ b/frappe/core/doctype/communication/communication.py
@@ -133,13 +133,13 @@ def send_comm_email(d, name, sent_via=None, print_html=None, attachments='[]', s
if print_html:
print_html = scrub_urls(print_html)
- outgoing_email_settings = frappe.get_doc("Outgoing Email Settings", "Outgoing Email Settings")
- send_print_as_pdf = cint(outgoing_email_settings.send_print_as_pdf)
+ print_settings = frappe.get_singles_dict("Print Settings")
+ send_print_as_pdf = cint(print_settings.send_print_as_pdf)
if send_print_as_pdf:
try:
options = {
- 'page-size': outgoing_email_settings.pdf_page_size or 'A4'
+ 'page-size': print_settings.pdf_page_size or 'A4'
}
mail.add_pdf_attachment(name.replace(' ','').replace('/','-') + '.pdf', print_html,
options=options)
diff --git a/frappe/core/doctype/outgoing_email_settings/outgoing_email_settings.json b/frappe/core/doctype/outgoing_email_settings/outgoing_email_settings.json
index fa8a587da5..7ae14e6256 100644
--- a/frappe/core/doctype/outgoing_email_settings/outgoing_email_settings.json
+++ b/frappe/core/doctype/outgoing_email_settings/outgoing_email_settings.json
@@ -75,27 +75,6 @@
"label": "Auto Email Id",
"permlevel": 0
},
- {
- "fieldname": "section_break_10",
- "fieldtype": "Section Break",
- "label": "Attaching Documents",
- "permlevel": 0
- },
- {
- "fieldname": "send_print_as_pdf",
- "fieldtype": "Check",
- "label": "Send Attached Document Print as PDF",
- "permlevel": 0
- },
- {
- "default": "A4",
- "depends_on": "eval:doc.send_print_as_pdf",
- "fieldname": "pdf_page_size",
- "fieldtype": "Select",
- "label": "PDF Page Size",
- "options": "A4\nLetter",
- "permlevel": 0
- },
{
"fieldname": "section_break_15",
"fieldtype": "Section Break",
@@ -115,7 +94,7 @@
"idx": 1,
"in_create": 1,
"issingle": 1,
- "modified": "2014-07-12 23:58:52.639998",
+ "modified": "2014-07-17 08:08:00.483391",
"modified_by": "Administrator",
"module": "Core",
"name": "Outgoing Email Settings",
diff --git a/frappe/core/doctype/print_settings/print_settings.js b/frappe/core/doctype/print_settings/print_settings.js
new file mode 100644
index 0000000000..207be09fcd
--- /dev/null
+++ b/frappe/core/doctype/print_settings/print_settings.js
@@ -0,0 +1,11 @@
+// Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and contributors
+// For license information, please see license.txt
+
+frappe.ui.form.on("Print Settings", "print_style", function (frm) {
+ frm.get_field("print_style_preview").html('');
+});
+
+frappe.ui.form.on("Print Settings", "onload", function (frm) {
+ frm.script_manager.trigger("print_style");
+});
diff --git a/frappe/core/doctype/print_settings/print_settings.json b/frappe/core/doctype/print_settings/print_settings.json
index 9d46dfe272..f1e365cbee 100644
--- a/frappe/core/doctype/print_settings/print_settings.json
+++ b/frappe/core/doctype/print_settings/print_settings.json
@@ -5,16 +5,38 @@
"document_type": "System",
"fields": [
{
- "fieldname": "print_style",
+ "fieldname": "pdf_settings",
+ "fieldtype": "Section Break",
+ "label": "PDF Settings",
+ "permlevel": 0
+ },
+ {
+ "description": "Send Email Print Attachments as PDF (Recommended)",
+ "fieldname": "send_print_as_pdf",
+ "fieldtype": "Check",
+ "label": "Send Print as PDF",
+ "permlevel": 0
+ },
+ {
+ "default": "A4",
+ "fieldname": "pdf_page_size",
"fieldtype": "Select",
- "in_list_view": 1,
+ "label": "PDF Page Size",
+ "options": "A4\nLetter",
+ "permlevel": 0
+ },
+ {
+ "fieldname": "print_style_section",
+ "fieldtype": "Section Break",
"label": "Print Style",
- "options": "Modern\nClassic\nStandard",
"permlevel": 0
},
{
- "fieldname": "column_break_2",
- "fieldtype": "Column Break",
+ "fieldname": "print_style",
+ "fieldtype": "Select",
+ "in_list_view": 1,
+ "label": "Print Style",
+ "options": "Modern\nClassic\nStandard",
"permlevel": 0
},
{
@@ -24,8 +46,9 @@
"permlevel": 0
}
],
+ "icon": "icon-cog",
"issingle": 1,
- "modified": "2014-07-17 06:54:20.782907",
+ "modified": "2014-07-17 08:08:27.291811",
"modified_by": "Administrator",
"module": "Core",
"name": "Print Settings",
diff --git a/frappe/database.py b/frappe/database.py
index 721de5576f..b38b0d967c 100644
--- a/frappe/database.py
+++ b/frappe/database.py
@@ -367,6 +367,10 @@ class Database:
return frappe._dict(self.sql("""select field, value from
tabSingles where doctype=%s""", doctype))
+ def get_single_value(self, doctype, fieldname):
+ val = self.sql("""select value from
+ tabSingles where doctype=%s and field=%s""", (doctype, fieldname))
+ return val[0][0] if val else None
def get_values_from_table(self, fields, filters, doctype, as_dict, debug, order_by=None, update=None):
fl = []
diff --git a/frappe/patches.txt b/frappe/patches.txt
index d4dcc6517b..abe17e867d 100644
--- a/frappe/patches.txt
+++ b/frappe/patches.txt
@@ -41,9 +41,9 @@ execute:frappe.reset_perms("User") #2014-06-13
execute:frappe.db.sql("""delete from `tabUserRole` where ifnull(parentfield, '')=''""") #2014-06-17
frappe.patches.v4_0.remove_user_owner_custom_field
execute:frappe.delete_doc("DocType", "Website Template")
-execute:frappe.reload_doc('website', 'doctype', 'website_route') #2014-06-17
+execute:frappe.reload_doc('website', 'doctype', 'website_route') #20114-06-17
execute:frappe.db.sql("""update `tabProperty Setter` set property_type='Text' where property in ('options', 'default')""") #2014-06-20
frappe.patches.v4_1.enable_outgoing_email_settings
execute:frappe.db.sql("""update `tabSingles` set `value`=`doctype` where `field`='name'""") #2014-07-04
-frappe.patches.v4_1.enable_print_as_pdf
+frappe.patches.v4_1.enable_print_as_pdf #2014-06-17
execute:frappe.db.sql("""update `tabDocPerm` set email=1 where parent='User' and permlevel=0 and `role`='All' and `read`=1 and apply_user_permissions=1""") #2014-07-15
diff --git a/frappe/patches/v4_1/enable_print_as_pdf.py b/frappe/patches/v4_1/enable_print_as_pdf.py
index d4d152c569..94cb96ff8b 100644
--- a/frappe/patches/v4_1/enable_print_as_pdf.py
+++ b/frappe/patches/v4_1/enable_print_as_pdf.py
@@ -5,10 +5,11 @@ from __future__ import unicode_literals
import frappe
def execute():
- frappe.reload_doc("core", "doctype", "outgoing_email_settings")
+ frappe.reload_doc("core", "doctype", "print_settings")
+ frappe.db.set_value("Print Settings", "Print Settings", "print_style", "Modern")
try:
import pdfkit
except ImportError:
pass
else:
- frappe.db.set_value("Outgoing Email Settings", "Outgoing Email Settings", "send_print_as_pdf", 1)
+ frappe.db.set_value("Print Settings", "Print Settings", "send_print_as_pdf", 1)
diff --git a/frappe/public/css/desk.css b/frappe/public/css/desk.css
index 8fd8da13d0..131e2722df 100644
--- a/frappe/public/css/desk.css
+++ b/frappe/public/css/desk.css
@@ -383,9 +383,11 @@ ul.linked-with-list li {
}
.print-preview {
- padding: 50px 20px;
- margin: 0px -15px;
+ padding: 0px;
+ max-width: 8.3in;
+ margin: auto;
box-shadow: 1px 1px 5px rgba(0,0,0,0.5);
+ min-height: 11.69in;
}
.module-view-layout {
diff --git a/frappe/public/images/help/print-style-classic.png b/frappe/public/images/help/print-style-classic.png
new file mode 100644
index 0000000000..6a2012e663
Binary files /dev/null and b/frappe/public/images/help/print-style-classic.png differ
diff --git a/frappe/public/images/help/print-style-modern.png b/frappe/public/images/help/print-style-modern.png
new file mode 100644
index 0000000000..591b56e901
Binary files /dev/null and b/frappe/public/images/help/print-style-modern.png differ
diff --git a/frappe/public/images/help/print-style-standard.png b/frappe/public/images/help/print-style-standard.png
new file mode 100644
index 0000000000..9236584007
Binary files /dev/null and b/frappe/public/images/help/print-style-standard.png differ
diff --git a/frappe/public/js/frappe/desk.js b/frappe/public/js/frappe/desk.js
index 96a9e4432a..36549fcedc 100644
--- a/frappe/public/js/frappe/desk.js
+++ b/frappe/public/js/frappe/desk.js
@@ -84,6 +84,9 @@ frappe.Application = Class.extend({
if(frappe.boot.timezone_info) {
moment.tz.add(frappe.boot.timezone_info);
}
+ if(frappe.boot.print_css) {
+ frappe.dom.set_style(frappe.boot.print_css)
+ }
} else {
this.set_as_guest();
}
diff --git a/frappe/public/js/frappe/form/control.js b/frappe/public/js/frappe/form/control.js
index 28f7e6241f..e82e05667e 100644
--- a/frappe/public/js/frappe/form/control.js
+++ b/frappe/public/js/frappe/form/control.js
@@ -96,6 +96,9 @@ frappe.ui.form.ControlHTML = frappe.ui.form.Control.extend({
if(me.df.options)
me.$wrapper.html(me.df.options);
})
+ },
+ html: function(html) {
+ this.$wrapper.html(html || me.df.options);
}
});
diff --git a/frappe/public/js/frappe/form/print.js b/frappe/public/js/frappe/form/print.js
index e8ac5f9ad9..a3f70ccdf7 100644
--- a/frappe/public/js/frappe/form/print.js
+++ b/frappe/public/js/frappe/form/print.js
@@ -21,7 +21,8 @@ frappe.ui.form.PrintPreview = Class.extend({
×\
\
\
-