@@ -51,6 +51,7 @@ def get_bootinfo(): | |||||
load_translations(bootinfo) | load_translations(bootinfo) | ||||
add_timezone_info(bootinfo) | add_timezone_info(bootinfo) | ||||
load_conf_settings(bootinfo) | load_conf_settings(bootinfo) | ||||
load_print_css(bootinfo) | |||||
# ipinfo | # ipinfo | ||||
if frappe.session['data'].get('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(user, bootinfo.timezone_info) | ||||
frappe.utils.momentjs.update(system, 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") |
@@ -133,13 +133,13 @@ def send_comm_email(d, name, sent_via=None, print_html=None, attachments='[]', s | |||||
if print_html: | if print_html: | ||||
print_html = scrub_urls(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: | if send_print_as_pdf: | ||||
try: | try: | ||||
options = { | 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, | mail.add_pdf_attachment(name.replace(' ','').replace('/','-') + '.pdf', print_html, | ||||
options=options) | options=options) | ||||
@@ -75,27 +75,6 @@ | |||||
"label": "Auto Email Id", | "label": "Auto Email Id", | ||||
"permlevel": 0 | "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", | "fieldname": "section_break_15", | ||||
"fieldtype": "Section Break", | "fieldtype": "Section Break", | ||||
@@ -115,7 +94,7 @@ | |||||
"idx": 1, | "idx": 1, | ||||
"in_create": 1, | "in_create": 1, | ||||
"issingle": 1, | "issingle": 1, | ||||
"modified": "2014-07-12 23:58:52.639998", | |||||
"modified": "2014-07-17 08:08:00.483391", | |||||
"modified_by": "Administrator", | "modified_by": "Administrator", | ||||
"module": "Core", | "module": "Core", | ||||
"name": "Outgoing Email Settings", | "name": "Outgoing Email Settings", | ||||
@@ -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('<img src="/assets/frappe/images/help/print-style-' + | |||||
frm.doc.print_style.toLowerCase() + '.png" class="img-responsive">'); | |||||
}); | |||||
frappe.ui.form.on("Print Settings", "onload", function (frm) { | |||||
frm.script_manager.trigger("print_style"); | |||||
}); |
@@ -5,16 +5,38 @@ | |||||
"document_type": "System", | "document_type": "System", | ||||
"fields": [ | "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", | "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", | "label": "Print Style", | ||||
"options": "Modern\nClassic\nStandard", | |||||
"permlevel": 0 | "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 | "permlevel": 0 | ||||
}, | }, | ||||
{ | { | ||||
@@ -24,8 +46,9 @@ | |||||
"permlevel": 0 | "permlevel": 0 | ||||
} | } | ||||
], | ], | ||||
"icon": "icon-cog", | |||||
"issingle": 1, | "issingle": 1, | ||||
"modified": "2014-07-17 06:54:20.782907", | |||||
"modified": "2014-07-17 08:08:27.291811", | |||||
"modified_by": "Administrator", | "modified_by": "Administrator", | ||||
"module": "Core", | "module": "Core", | ||||
"name": "Print Settings", | "name": "Print Settings", | ||||
@@ -367,6 +367,10 @@ class Database: | |||||
return frappe._dict(self.sql("""select field, value from | return frappe._dict(self.sql("""select field, value from | ||||
tabSingles where doctype=%s""", doctype)) | 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): | def get_values_from_table(self, fields, filters, doctype, as_dict, debug, order_by=None, update=None): | ||||
fl = [] | fl = [] | ||||
@@ -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 | execute:frappe.db.sql("""delete from `tabUserRole` where ifnull(parentfield, '')=''""") #2014-06-17 | ||||
frappe.patches.v4_0.remove_user_owner_custom_field | frappe.patches.v4_0.remove_user_owner_custom_field | ||||
execute:frappe.delete_doc("DocType", "Website Template") | 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 | 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 | frappe.patches.v4_1.enable_outgoing_email_settings | ||||
execute:frappe.db.sql("""update `tabSingles` set `value`=`doctype` where `field`='name'""") #2014-07-04 | 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 | 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 |
@@ -5,10 +5,11 @@ from __future__ import unicode_literals | |||||
import frappe | import frappe | ||||
def execute(): | 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: | try: | ||||
import pdfkit | import pdfkit | ||||
except ImportError: | except ImportError: | ||||
pass | pass | ||||
else: | 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) |
@@ -383,9 +383,11 @@ ul.linked-with-list li { | |||||
} | } | ||||
.print-preview { | .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); | box-shadow: 1px 1px 5px rgba(0,0,0,0.5); | ||||
min-height: 11.69in; | |||||
} | } | ||||
.module-view-layout { | .module-view-layout { | ||||
@@ -84,6 +84,9 @@ frappe.Application = Class.extend({ | |||||
if(frappe.boot.timezone_info) { | if(frappe.boot.timezone_info) { | ||||
moment.tz.add(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 { | } else { | ||||
this.set_as_guest(); | this.set_as_guest(); | ||||
} | } | ||||
@@ -96,6 +96,9 @@ frappe.ui.form.ControlHTML = frappe.ui.form.Control.extend({ | |||||
if(me.df.options) | if(me.df.options) | ||||
me.$wrapper.html(me.df.options); | me.$wrapper.html(me.df.options); | ||||
}) | }) | ||||
}, | |||||
html: function(html) { | |||||
this.$wrapper.html(html || me.df.options); | |||||
} | } | ||||
}); | }); | ||||
@@ -21,7 +21,8 @@ frappe.ui.form.PrintPreview = Class.extend({ | |||||
<a class="close">×</a>\ | <a class="close">×</a>\ | ||||
</div>\ | </div>\ | ||||
</div>\ | </div>\ | ||||
<div class="print-preview" style="padding: 50px; min-height: 1000px;">\ | |||||
<div class="print-preview">\ | |||||
<div class="print-format"></div>\ | |||||
</div>\ | </div>\ | ||||
</div>') | </div>') | ||||
.appendTo(this.frm.layout_main) | .appendTo(this.frm.layout_main) | ||||
@@ -66,7 +67,7 @@ frappe.ui.form.PrintPreview = Class.extend({ | |||||
preview: function() { | preview: function() { | ||||
var me = this; | var me = this; | ||||
this.get_print_html(function(html) { | this.get_print_html(function(html) { | ||||
me.wrapper.find(".print-preview").html(html); | |||||
me.wrapper.find(".print-format").html(html); | |||||
}); | }); | ||||
}, | }, | ||||
printit: function() { | printit: function() { | ||||
@@ -11,9 +11,11 @@ | |||||
</style> | </style> | ||||
</head> | </head> | ||||
<body> | <body> | ||||
<div class="print-format"> | |||||
{{ body }} | |||||
</div> | |||||
<div class="print-format-gutter"> | |||||
<div class="print-format"> | |||||
{{ body }} | |||||
</div> | |||||
</div> | |||||
</body> | </body> | ||||
{%- if comment -%} | {%- if comment -%} | ||||
<!-- {{ comment }} --> | <!-- {{ comment }} --> | ||||
@@ -108,19 +108,6 @@ def get_print_format(doctype, format_name): | |||||
frappe.throw(_("No template found at path: {0}").format(path), | frappe.throw(_("No template found at path: {0}").format(path), | ||||
frappe.TemplateNotFoundError) | frappe.TemplateNotFoundError) | ||||
def get_print_style(style=None): | |||||
if not style: | |||||
style = frappe.db.get_default("print_style") or "Standard" | |||||
css = frappe.get_template("templates/styles/standard.css").render() | |||||
try: | |||||
css += frappe.get_template("templates/styles/" + style.lower() + ".css").render() | |||||
except TemplateNotFound: | |||||
pass | |||||
return css | |||||
def make_layout(doc, meta): | def make_layout(doc, meta): | ||||
layout, page = [], [] | layout, page = [], [] | ||||
layout.append(page) | layout.append(page) | ||||
@@ -163,4 +150,16 @@ def is_visible(df): | |||||
no_display = ("Section Break", "Column Break", "Button") | no_display = ("Section Break", "Column Break", "Button") | ||||
return (df.fieldtype not in no_display) and df.label and not df.print_hide | return (df.fieldtype not in no_display) and df.label and not df.print_hide | ||||
def get_print_style(style=None): | |||||
if not style: | |||||
style = frappe.db.get_default("print_style") or "Standard" | |||||
css = frappe.get_template("templates/styles/standard.css").render() | |||||
try: | |||||
css += frappe.get_template("templates/styles/" + style.lower() + ".css").render() | |||||
except TemplateNotFound: | |||||
pass | |||||
return css | |||||
@@ -114,7 +114,7 @@ | |||||
{% for section in page %} | {% for section in page %} | ||||
<div class="row"> | <div class="row"> | ||||
{% for column in section %} | {% for column in section %} | ||||
<div class="col-md-{{ (12 / section|len)|int }}"> | |||||
<div class="col-sm-{{ (12 / section|len)|int }}"> | |||||
{% for df in column %} | {% for df in column %} | ||||
{{ render_field(df) }} | {{ render_field(df) }} | ||||
{% endfor %} | {% endfor %} | ||||
@@ -1,19 +1,35 @@ | |||||
@media screen { | @media screen { | ||||
.print-format-gutter { | |||||
background-color: #ddd; | |||||
padding: 15px 0px; | |||||
} | |||||
.print-format { | .print-format { | ||||
width: 8.3in; | |||||
background-color: white; | |||||
box-shadow: 0px 0px 9px rgba(0,0,0,0.5); | |||||
max-width: 8.3in; | |||||
min-height: 11.69in; | |||||
padding: 0.75in; | |||||
margin: auto; | margin: auto; | ||||
} | } | ||||
.page-break { | .page-break { | ||||
padding: 30px 10px; | |||||
padding: 30px 0px; | |||||
border-bottom: 1px dashed #888; | border-bottom: 1px dashed #888; | ||||
} | } | ||||
.page-break:first-child { | |||||
padding-top: 0px; | |||||
} | |||||
.page-break:last-child { | .page-break:last-child { | ||||
border-bottom: 0px; | border-bottom: 0px; | ||||
} | } | ||||
} | } | ||||
.print-format { | |||||
font-size: 9pt; | |||||
} | |||||
.page-break { | .page-break { | ||||
page-break-after: always; | page-break-after: always; | ||||
} | } | ||||
@@ -24,7 +40,7 @@ | |||||
} | } | ||||
.print-heading h2 { | .print-heading h2 { | ||||
margin-bottom: 0px; | |||||
margin: 0px; | |||||
} | } | ||||
.print-heading h4 { | .print-heading h4 { | ||||
margin-top: 5px; | margin-top: 5px; | ||||