Browse Source

added print settings print style fixes etc.

version-14
Rushabh Mehta 11 years ago
committed by Anand Doshi
parent
commit
8f022029a8
19 changed files with 107 additions and 59 deletions
  1. +4
    -0
      frappe/boot.py
  2. +3
    -3
      frappe/core/doctype/communication/communication.py
  3. +1
    -22
      frappe/core/doctype/outgoing_email_settings/outgoing_email_settings.json
  4. +11
    -0
      frappe/core/doctype/print_settings/print_settings.js
  5. +29
    -6
      frappe/core/doctype/print_settings/print_settings.json
  6. +4
    -0
      frappe/database.py
  7. +2
    -2
      frappe/patches.txt
  8. +3
    -2
      frappe/patches/v4_1/enable_print_as_pdf.py
  9. +4
    -2
      frappe/public/css/desk.css
  10. BIN
      frappe/public/images/help/print-style-classic.png
  11. BIN
      frappe/public/images/help/print-style-modern.png
  12. BIN
      frappe/public/images/help/print-style-standard.png
  13. +3
    -0
      frappe/public/js/frappe/desk.js
  14. +3
    -0
      frappe/public/js/frappe/form/control.js
  15. +3
    -2
      frappe/public/js/frappe/form/print.js
  16. +5
    -3
      frappe/templates/pages/print.html
  17. +12
    -13
      frappe/templates/pages/print.py
  18. +1
    -1
      frappe/templates/print_formats/standard.html
  19. +19
    -3
      frappe/templates/styles/standard.css

+ 4
- 0
frappe/boot.py View File

@@ -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")

+ 3
- 3
frappe/core/doctype/communication/communication.py View File

@@ -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)


+ 1
- 22
frappe/core/doctype/outgoing_email_settings/outgoing_email_settings.json View File

@@ -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",


+ 11
- 0
frappe/core/doctype/print_settings/print_settings.js View File

@@ -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");
});

+ 29
- 6
frappe/core/doctype/print_settings/print_settings.json View File

@@ -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",


+ 4
- 0
frappe/database.py View File

@@ -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 = []


+ 2
- 2
frappe/patches.txt View File

@@ -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

+ 3
- 2
frappe/patches/v4_1/enable_print_as_pdf.py View File

@@ -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)

+ 4
- 2
frappe/public/css/desk.css View File

@@ -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 {


BIN
frappe/public/images/help/print-style-classic.png View File

Before After
Width: 1058  |  Height: 798  |  Size: 105 KiB

BIN
frappe/public/images/help/print-style-modern.png View File

Before After
Width: 1058  |  Height: 798  |  Size: 108 KiB

BIN
frappe/public/images/help/print-style-standard.png View File

Before After
Width: 1058  |  Height: 798  |  Size: 108 KiB

+ 3
- 0
frappe/public/js/frappe/desk.js View File

@@ -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();
}


+ 3
- 0
frappe/public/js/frappe/form/control.js View File

@@ -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);
}
});



+ 3
- 2
frappe/public/js/frappe/form/print.js View File

@@ -21,7 +21,8 @@ frappe.ui.form.PrintPreview = Class.extend({
<a class="close">×</a>\
</div>\
</div>\
<div class="print-preview" style="padding: 50px; min-height: 1000px;">\
<div class="print-preview">\
<div class="print-format"></div>\
</div>\
</div>')
.appendTo(this.frm.layout_main)
@@ -66,7 +67,7 @@ frappe.ui.form.PrintPreview = Class.extend({
preview: function() {
var me = this;
this.get_print_html(function(html) {
me.wrapper.find(".print-preview").html(html);
me.wrapper.find(".print-format").html(html);
});
},
printit: function() {


+ 5
- 3
frappe/templates/pages/print.html View File

@@ -11,9 +11,11 @@
</style>
</head>
<body>
<div class="print-format">
{{ body }}
</div>
<div class="print-format-gutter">
<div class="print-format">
{{ body }}
</div>
</div>
</body>
{%- if comment -%}
<!-- {{ comment }} -->


+ 12
- 13
frappe/templates/pages/print.py View File

@@ -108,19 +108,6 @@ def get_print_format(doctype, format_name):
frappe.throw(_("No template found at path: {0}").format(path),
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):
layout, page = [], []
layout.append(page)
@@ -163,4 +150,16 @@ def is_visible(df):
no_display = ("Section Break", "Column Break", "Button")
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


+ 1
- 1
frappe/templates/print_formats/standard.html View File

@@ -114,7 +114,7 @@
{% for section in page %}
<div class="row">
{% for column in section %}
<div class="col-md-{{ (12 / section|len)|int }}">
<div class="col-sm-{{ (12 / section|len)|int }}">
{% for df in column %}
{{ render_field(df) }}
{% endfor %}


+ 19
- 3
frappe/templates/styles/standard.css View File

@@ -1,19 +1,35 @@
@media screen {
.print-format-gutter {
background-color: #ddd;
padding: 15px 0px;
}
.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;
}

.page-break {
padding: 30px 10px;
padding: 30px 0px;
border-bottom: 1px dashed #888;
}

.page-break:first-child {
padding-top: 0px;
}

.page-break:last-child {
border-bottom: 0px;
}
}

.print-format {
font-size: 9pt;
}

.page-break {
page-break-after: always;
}
@@ -24,7 +40,7 @@
}

.print-heading h2 {
margin-bottom: 0px;
margin: 0px;
}
.print-heading h4 {
margin-top: 5px;


Loading…
Cancel
Save