Commit 74a2069d authored by Xiaowu Zhang's avatar Xiaowu Zhang

erp5_corporate_identity: possible to add custom header and footer

parent cc7b8d71
......@@ -50,6 +50,8 @@ return context.Base_viewAsReport(
display_milestone=display_milestone,
report_name=report_name,
report_title=report_title,
report_header = report_header,
report_footer = report_footer,
start_date=start_date,
stop_date=stop_date,
batch_mode=batch_mode,
......
......@@ -50,7 +50,7 @@
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>format=\'pdf\', batch_mode=None, override_source_organisation_title=None, document_save=None, display_milestone=None, document_download=None, document_language=None, document_reference=None, document_version=None, display_header=None, display_detail=None, display_comment=None, document_title=None, display_depth=None, report_title=None, display_orphan=None, report_name=None, start_date=None, stop_date=None, *args,**kw</string> </value>
<value> <string>format=\'pdf\', batch_mode=None, override_source_organisation_title=None, document_save=None, display_milestone=None, document_download=None, document_language=None, document_reference=None, document_version=None, display_header=None, display_detail=None, display_comment=None, document_title=None, display_depth=None, report_title=None, display_orphan=None, report_name=None, start_date=None, stop_date=None, report_header=None, report_footer=None,*args,**kw</string> </value>
</item>
<item>
<key> <string>id</string> </key>
......
......@@ -34,6 +34,7 @@ MAIN FILE: generate report (book header/footer and report content)
# --------
# report_name report to generate
# report_title report title
# report_header custom report header
from Products.PythonScripts.standard import html_quote
from base64 import b64encode
......@@ -95,6 +96,19 @@ doc_translated_title = translateText(doc_report_title) if doc_report_title else
if doc_language is None or doc_language == "":
doc_language = doc_localiser.get_selected_language() or doc_localiser.get_default_language() or "en"
# custom header
doc_header = None
doc_report_header = kw.get('report_header', None)
if doc_report_header:
doc_report_header = getattr(doc, doc_report_header)
doc_header = doc_report_header()
doc_footer = None
doc_report_footer = kw.get('report_footer', None)
if doc_report_footer:
doc_report_footer = getattr(doc, doc_report_footer)
doc_footer = doc_report_footer()
doc_content, report_override_doc_title, report_override_doc_subtitle = doc_report(
display_report=None if doc_embed else True,
format=doc_format,
......@@ -173,6 +187,8 @@ if doc_format == "html":
book_full_reference=doc_full_reference,
book_source_organisation_title=doc_source.get("organisation_title") or blank,
book_content=doc_content,
book_header = doc_header,
book_footer = doc_footer
)
return doc.Base_finishWebPageCreation(
......@@ -218,6 +234,7 @@ if doc_format == "pdf":
book_revision=doc_revision,
book_version=doc_version,
book_short_date=doc_short_date,
book_header = doc_header
)
doc_foot = doc.WebPage_createBookFooter(
......@@ -231,6 +248,7 @@ if doc_format == "pdf":
book_template_css_url=doc_theme.get("template_css_url"),
book_full_reference=doc_full_reference,
book_source_organisation_title=doc_source.get("organisation_title") or blank,
book_footer = doc_footer
)
# ================ encode and build cloudoo elements =========================
......
......@@ -8,6 +8,8 @@ Generates the complete book (only called in HTML version)
<tal:block tal:define="book_raw_tables python: options.get('book_raw_tables');
book_raw_report python: options.get('book_raw_report');
book_theme python: options.get('book_theme');
book_header python: options.get('book_header');
book_footer python: options.get('book_footer');
book_title python: options.get('book_title');
book_language python: options.get('book_language');
book_theme_css_font_list python: options.get('book_theme_css_font_list');
......
......@@ -7,6 +7,7 @@ Creates the Book footer.
</tal:comment>
<tal:block tal:define="book_theme python: options.get('book_theme');
book_title python: options.get('book_title');
book_footer python: options.get('book_footer');
book_language python: options.get('book_language');
book_theme_css_font_list python: options.get('book_theme_css_font_list');
book_theme_css_url python: options.get('book_theme_css_url');
......@@ -41,6 +42,10 @@ Creates the Book footer.
<tal:block tal:condition="python: False">
<tal:block metal:define-macro="book_footer">
<tal:block tal:condition="python: book_footer">
<tal:block tal:content="structure python: book_footer"></tal:block>
</tal:block>
<tal:block tal:condition="python: not book_footer">
<table class="ci-book-footer">
<tbody>
<tr>
......@@ -51,4 +56,5 @@ Creates the Book footer.
</tbody>
</table>
</tal:block>
</tal:block>
</tal:block>
\ No newline at end of file
......@@ -7,6 +7,7 @@ Creates the Book header.
</tal:comment>
<tal:block tal:define="book_theme python: options.get('book_theme');
book_title python: options.get('book_title');
book_header python: options.get('book_header');
book_language python: options.get('book_language');
book_theme_css_font_list python: options.get('book_theme_css_font_list');
book_theme_css_url python: options.get('book_theme_css_url');
......@@ -66,6 +67,10 @@ Creates the Book header.
<tal:block tal:condition="python: False">
<tal:block metal:define-macro="book_header">
<tal:block tal:condition="python: book_header">
<tal:block tal:content="structure python: book_header"></tal:block>
</tal:block>
<tal:block tal:condition="python: not book_header">
<table class="ci-book-header">
<tbody>
<tr>
......@@ -106,4 +111,5 @@ Creates the Book header.
</tbody>
</table>
</tal:block>
</tal:block>
</tal:block>
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment