1 parent
1d4749b194
commit
db616f9b97
13 files changed
+3617
-1
No files matched your search
@@ -0,0 +1,188 @@
|
|||||||
|
[
|
||||||
|
{
|
||||||
|
"alignment": "",
|
||||||
|
"allow_bulk_edit": 0,
|
||||||
|
"allow_in_quick_entry": 0,
|
||||||
|
"allow_on_submit": 0,
|
||||||
|
"bold": 0,
|
||||||
|
"button_color": "",
|
||||||
|
"collapsible": 0,
|
||||||
|
"collapsible_depends_on": null,
|
||||||
|
"columns": 0,
|
||||||
|
"default": null,
|
||||||
|
"depends_on": null,
|
||||||
|
"description": null,
|
||||||
|
"docstatus": 0,
|
||||||
|
"doctype": "Custom Field",
|
||||||
|
"dt": "Network Printer Settings",
|
||||||
|
"fetch_from": null,
|
||||||
|
"fetch_if_empty": 0,
|
||||||
|
"fieldname": "custom_label_composer",
|
||||||
|
"fieldtype": "Section Break",
|
||||||
|
"hidden": 0,
|
||||||
|
"hide_border": 0,
|
||||||
|
"hide_days": 0,
|
||||||
|
"hide_seconds": 0,
|
||||||
|
"ignore_user_permissions": 0,
|
||||||
|
"ignore_xss_filter": 0,
|
||||||
|
"in_global_search": 0,
|
||||||
|
"in_list_view": 0,
|
||||||
|
"in_preview": 0,
|
||||||
|
"in_standard_filter": 0,
|
||||||
|
"insert_after": "printer_name",
|
||||||
|
"is_system_generated": 0,
|
||||||
|
"is_virtual": 0,
|
||||||
|
"label": "Label Composer",
|
||||||
|
"length": 0,
|
||||||
|
"link_filters": null,
|
||||||
|
"mandatory_depends_on": null,
|
||||||
|
"mask": 0,
|
||||||
|
"modified": "2026-10-25 14:29:20.007352",
|
||||||
|
"module": null,
|
||||||
|
"name": "Network Printer Settings-custom_label_composer",
|
||||||
|
"no_copy": 0,
|
||||||
|
"non_negative": 0,
|
||||||
|
"options": null,
|
||||||
|
"permlevel": 0,
|
||||||
|
"placeholder": null,
|
||||||
|
"precision": "",
|
||||||
|
"print_hide": 0,
|
||||||
|
"print_hide_if_no_value": 0,
|
||||||
|
"print_width": null,
|
||||||
|
"read_only": 0,
|
||||||
|
"read_only_depends_on": null,
|
||||||
|
"report_hide": 0,
|
||||||
|
"reqd": 0,
|
||||||
|
"search_index": 0,
|
||||||
|
"set_only_once": 0,
|
||||||
|
"show_dashboard": 0,
|
||||||
|
"sort_options": 0,
|
||||||
|
"translatable": 0,
|
||||||
|
"unique": 0,
|
||||||
|
"width": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"alignment": "",
|
||||||
|
"allow_bulk_edit": 0,
|
||||||
|
"allow_in_quick_entry": 0,
|
||||||
|
"allow_on_submit": 0,
|
||||||
|
"bold": 0,
|
||||||
|
"button_color": "",
|
||||||
|
"collapsible": 0,
|
||||||
|
"collapsible_depends_on": null,
|
||||||
|
"columns": 0,
|
||||||
|
"default": null,
|
||||||
|
"depends_on": null,
|
||||||
|
"description": null,
|
||||||
|
"docstatus": 0,
|
||||||
|
"doctype": "Custom Field",
|
||||||
|
"dt": "Network Printer Settings",
|
||||||
|
"fetch_from": null,
|
||||||
|
"fetch_if_empty": 0,
|
||||||
|
"fieldname": "custom_paper_width_mm",
|
||||||
|
"fieldtype": "Float",
|
||||||
|
"hidden": 0,
|
||||||
|
"hide_border": 0,
|
||||||
|
"hide_days": 0,
|
||||||
|
"hide_seconds": 0,
|
||||||
|
"ignore_user_permissions": 0,
|
||||||
|
"ignore_xss_filter": 0,
|
||||||
|
"in_global_search": 0,
|
||||||
|
"in_list_view": 0,
|
||||||
|
"in_preview": 0,
|
||||||
|
"in_standard_filter": 0,
|
||||||
|
"insert_after": "custom_label_composer",
|
||||||
|
"is_system_generated": 0,
|
||||||
|
"is_virtual": 0,
|
||||||
|
"label": "Paper Width (mm)",
|
||||||
|
"length": 0,
|
||||||
|
"link_filters": null,
|
||||||
|
"mandatory_depends_on": null,
|
||||||
|
"mask": 0,
|
||||||
|
"modified": "2026-10-25 14:29:20.138647",
|
||||||
|
"module": null,
|
||||||
|
"name": "Network Printer Settings-custom_paper_width_mm",
|
||||||
|
"no_copy": 0,
|
||||||
|
"non_negative": 0,
|
||||||
|
"options": null,
|
||||||
|
"permlevel": 0,
|
||||||
|
"placeholder": null,
|
||||||
|
"precision": "1",
|
||||||
|
"print_hide": 0,
|
||||||
|
"print_hide_if_no_value": 0,
|
||||||
|
"print_width": null,
|
||||||
|
"read_only": 0,
|
||||||
|
"read_only_depends_on": null,
|
||||||
|
"report_hide": 0,
|
||||||
|
"reqd": 0,
|
||||||
|
"search_index": 0,
|
||||||
|
"set_only_once": 0,
|
||||||
|
"show_dashboard": 0,
|
||||||
|
"sort_options": 0,
|
||||||
|
"translatable": 0,
|
||||||
|
"unique": 0,
|
||||||
|
"width": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"alignment": "",
|
||||||
|
"allow_bulk_edit": 0,
|
||||||
|
"allow_in_quick_entry": 0,
|
||||||
|
"allow_on_submit": 0,
|
||||||
|
"bold": 0,
|
||||||
|
"button_color": "",
|
||||||
|
"collapsible": 0,
|
||||||
|
"collapsible_depends_on": null,
|
||||||
|
"columns": 0,
|
||||||
|
"default": null,
|
||||||
|
"depends_on": null,
|
||||||
|
"description": null,
|
||||||
|
"docstatus": 0,
|
||||||
|
"doctype": "Custom Field",
|
||||||
|
"dt": "Network Printer Settings",
|
||||||
|
"fetch_from": null,
|
||||||
|
"fetch_if_empty": 0,
|
||||||
|
"fieldname": "custom_paper_height_mm",
|
||||||
|
"fieldtype": "Float",
|
||||||
|
"hidden": 0,
|
||||||
|
"hide_border": 0,
|
||||||
|
"hide_days": 0,
|
||||||
|
"hide_seconds": 0,
|
||||||
|
"ignore_user_permissions": 0,
|
||||||
|
"ignore_xss_filter": 0,
|
||||||
|
"in_global_search": 0,
|
||||||
|
"in_list_view": 0,
|
||||||
|
"in_preview": 0,
|
||||||
|
"in_standard_filter": 0,
|
||||||
|
"insert_after": "custom_column_break_pcoln",
|
||||||
|
"is_system_generated": 0,
|
||||||
|
"is_virtual": 0,
|
||||||
|
"label": "Paper Height (mm)",
|
||||||
|
"length": 0,
|
||||||
|
"link_filters": null,
|
||||||
|
"mandatory_depends_on": null,
|
||||||
|
"mask": 0,
|
||||||
|
"modified": "2026-10-25 14:29:20.230068",
|
||||||
|
"module": null,
|
||||||
|
"name": "Network Printer Settings-custom_paper_height_mm",
|
||||||
|
"no_copy": 0,
|
||||||
|
"non_negative": 0,
|
||||||
|
"options": null,
|
||||||
|
"permlevel": 0,
|
||||||
|
"placeholder": null,
|
||||||
|
"precision": "1",
|
||||||
|
"print_hide": 0,
|
||||||
|
"print_hide_if_no_value": 0,
|
||||||
|
"print_width": null,
|
||||||
|
"read_only": 0,
|
||||||
|
"read_only_depends_on": null,
|
||||||
|
"report_hide": 0,
|
||||||
|
"reqd": 0,
|
||||||
|
"search_index": 0,
|
||||||
|
"set_only_once": 0,
|
||||||
|
"show_dashboard": 0,
|
||||||
|
"sort_options": 0,
|
||||||
|
"translatable": 0,
|
||||||
|
"unique": 0,
|
||||||
|
"width": null
|
||||||
|
}
|
||||||
|
]
|
||||||
@@ -37,6 +37,14 @@ app_license = "gpl-3.0"
|
|||||||
# app_include_css = "/assets/manufacturing_utilities/css/manufacturing_utilities.css"
|
# app_include_css = "/assets/manufacturing_utilities/css/manufacturing_utilities.css"
|
||||||
# app_include_js = "/assets/manufacturing_utilities/js/manufacturing_utilities.js"
|
# app_include_js = "/assets/manufacturing_utilities/js/manufacturing_utilities.js"
|
||||||
|
|
||||||
|
app_include_js = [
|
||||||
|
"/assets/manufacturing_utilities/js/label_composer.js",
|
||||||
|
]
|
||||||
|
|
||||||
|
app_include_css = [
|
||||||
|
"/assets/manufacturing_utilities/css/label_composer.css",
|
||||||
|
]
|
||||||
|
|
||||||
# include js, css files in header of web template
|
# include js, css files in header of web template
|
||||||
# web_include_css = "/assets/manufacturing_utilities/css/manufacturing_utilities.css"
|
# web_include_css = "/assets/manufacturing_utilities/css/manufacturing_utilities.css"
|
||||||
# web_include_js = "/assets/manufacturing_utilities/js/manufacturing_utilities.js"
|
# web_include_js = "/assets/manufacturing_utilities/js/manufacturing_utilities.js"
|
||||||
@@ -298,5 +306,16 @@ fixtures = [
|
|||||||
"filters": [
|
"filters": [
|
||||||
["name", "=", "Manufacturing Overview"]
|
["name", "=", "Manufacturing Overview"]
|
||||||
]
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"dt": "Custom Field",
|
||||||
|
"filters": [
|
||||||
|
["dt", "=", "Network Printer Settings"],
|
||||||
|
["fieldname", "in", [
|
||||||
|
"custom_label_composer",
|
||||||
|
"custom_paper_width_mm",
|
||||||
|
"custom_paper_height_mm"
|
||||||
|
]]
|
||||||
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
File renamed without changes.
@@ -0,0 +1,672 @@
|
|||||||
|
|
||||||
|
"""Label Composer for Frappe / ERPNext v16.
|
||||||
|
|
||||||
|
- Live HTML/Jinja preview in the requested print language
|
||||||
|
- PDF generation at the configured physical label size
|
||||||
|
- CUPS submission with group-specific copy counts
|
||||||
|
- No individual label documents are created or saved
|
||||||
|
"""
|
||||||
|
|
||||||
|
import base64
|
||||||
|
import math
|
||||||
|
import os
|
||||||
|
import tempfile
|
||||||
|
from io import BytesIO
|
||||||
|
|
||||||
|
import frappe
|
||||||
|
from frappe import _
|
||||||
|
from frappe.translate import print_language
|
||||||
|
from frappe.utils import cint, flt, getdate
|
||||||
|
from frappe.utils.html_utils import sanitize_html
|
||||||
|
from frappe.www.printview import get_print_style, get_rendered_template
|
||||||
|
from pypdf import PdfReader
|
||||||
|
|
||||||
|
|
||||||
|
TEMPLATE_DOCTYPE = "Label Composer Template"
|
||||||
|
|
||||||
|
MAX_GROUPS = 30
|
||||||
|
MAX_COPIES_PER_GROUP = 500
|
||||||
|
MAX_TOTAL_LABELS = 1000
|
||||||
|
|
||||||
|
LABEL_FIELDS = {
|
||||||
|
"Customer Label": (
|
||||||
|
"customer",
|
||||||
|
"item_code",
|
||||||
|
"item_name",
|
||||||
|
"quantity",
|
||||||
|
"delivery_date",
|
||||||
|
),
|
||||||
|
"Warehouse Label": (
|
||||||
|
"customer",
|
||||||
|
"item_code",
|
||||||
|
"item_name",
|
||||||
|
),
|
||||||
|
"Supplier Label": (
|
||||||
|
"supplier",
|
||||||
|
"item_code",
|
||||||
|
"item_name",
|
||||||
|
"quantity",
|
||||||
|
"delivery_date",
|
||||||
|
),
|
||||||
|
"Generic Label": (
|
||||||
|
"free_text",
|
||||||
|
),
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
def _require_login():
|
||||||
|
if frappe.session.user == "Guest":
|
||||||
|
frappe.throw(_("Login required"), frappe.PermissionError)
|
||||||
|
|
||||||
|
|
||||||
|
def _parse_values(values):
|
||||||
|
parsed = frappe.parse_json(values) if values else {}
|
||||||
|
|
||||||
|
if not isinstance(parsed, dict):
|
||||||
|
frappe.throw(_("Label values must be an object"))
|
||||||
|
|
||||||
|
if len(parsed) > 20:
|
||||||
|
frappe.throw(_("Too many label fields"))
|
||||||
|
|
||||||
|
return parsed
|
||||||
|
|
||||||
|
|
||||||
|
def _get_print_language(values):
|
||||||
|
"""Validate the selected Frappe Language without changing user settings."""
|
||||||
|
|
||||||
|
language = values.get("language") or frappe.local.lang or "en"
|
||||||
|
|
||||||
|
if not isinstance(language, str):
|
||||||
|
frappe.throw(_("Invalid print language"))
|
||||||
|
|
||||||
|
language = language.strip()
|
||||||
|
|
||||||
|
if len(language) > 20:
|
||||||
|
frappe.throw(_("Invalid print language"))
|
||||||
|
|
||||||
|
if not frappe.db.exists(
|
||||||
|
"Language",
|
||||||
|
{"name": language, "enabled": 1},
|
||||||
|
):
|
||||||
|
frappe.throw(
|
||||||
|
_("Print language {0} is not enabled").format(language)
|
||||||
|
)
|
||||||
|
|
||||||
|
return language
|
||||||
|
|
||||||
|
|
||||||
|
def _get_configuration(label_type):
|
||||||
|
if label_type not in LABEL_FIELDS:
|
||||||
|
frappe.throw(_("Unknown label type"))
|
||||||
|
|
||||||
|
if not frappe.db.exists(TEMPLATE_DOCTYPE, label_type):
|
||||||
|
return None, _("No Label Composer Template configured")
|
||||||
|
|
||||||
|
template = frappe.get_doc(TEMPLATE_DOCTYPE, label_type)
|
||||||
|
template.check_permission("read")
|
||||||
|
|
||||||
|
if not template.enabled:
|
||||||
|
return None, _("This label template is disabled")
|
||||||
|
|
||||||
|
if not template.print_format:
|
||||||
|
return None, _("No Print Format configured")
|
||||||
|
|
||||||
|
if not template.default_printer:
|
||||||
|
return None, _("No default printer configured")
|
||||||
|
|
||||||
|
if not frappe.db.exists("Print Format", template.print_format):
|
||||||
|
return None, _("Configured Print Format not found")
|
||||||
|
|
||||||
|
print_format = frappe.get_doc(
|
||||||
|
"Print Format",
|
||||||
|
template.print_format,
|
||||||
|
)
|
||||||
|
|
||||||
|
if print_format.doc_type != TEMPLATE_DOCTYPE:
|
||||||
|
frappe.throw(
|
||||||
|
_("The Print Format belongs to a different DocType")
|
||||||
|
)
|
||||||
|
|
||||||
|
if print_format.disabled:
|
||||||
|
return None, _("The selected Print Format is disabled")
|
||||||
|
|
||||||
|
printer = frappe.get_doc(
|
||||||
|
"Network Printer Settings",
|
||||||
|
template.default_printer,
|
||||||
|
)
|
||||||
|
printer.check_permission("read")
|
||||||
|
|
||||||
|
width = flt(printer.custom_paper_width_mm)
|
||||||
|
height = flt(printer.custom_paper_height_mm)
|
||||||
|
|
||||||
|
if not (10 <= width <= 600 and 10 <= height <= 600):
|
||||||
|
return None, _("Invalid paper dimensions in printer settings")
|
||||||
|
|
||||||
|
return {
|
||||||
|
"template": template,
|
||||||
|
"print_format": print_format,
|
||||||
|
"printer": printer,
|
||||||
|
"width": width,
|
||||||
|
"height": height,
|
||||||
|
}, None
|
||||||
|
|
||||||
|
|
||||||
|
def _prepare_document(template, label_type, values):
|
||||||
|
"""Fill an existing configuration document in memory only."""
|
||||||
|
|
||||||
|
doc = frappe.get_doc(TEMPLATE_DOCTYPE, template.name)
|
||||||
|
doc.check_permission("read")
|
||||||
|
|
||||||
|
for fieldname in LABEL_FIELDS[label_type]:
|
||||||
|
value = values.get(fieldname)
|
||||||
|
|
||||||
|
if fieldname == "quantity":
|
||||||
|
if (
|
||||||
|
isinstance(value, bool)
|
||||||
|
or not str(
|
||||||
|
value if value is not None else ""
|
||||||
|
).strip()
|
||||||
|
):
|
||||||
|
frappe.throw(
|
||||||
|
_("Label quantity must be greater than zero")
|
||||||
|
)
|
||||||
|
|
||||||
|
try:
|
||||||
|
quantity = float(value)
|
||||||
|
except (TypeError, ValueError):
|
||||||
|
frappe.throw(_("Invalid label quantity"))
|
||||||
|
|
||||||
|
if not math.isfinite(quantity) or quantity <= 0:
|
||||||
|
frappe.throw(
|
||||||
|
_("Label quantity must be greater than zero")
|
||||||
|
)
|
||||||
|
|
||||||
|
# No check against the ordered quantity.
|
||||||
|
# Overproduction and partial packaging are allowed.
|
||||||
|
doc.set(fieldname, quantity)
|
||||||
|
continue
|
||||||
|
|
||||||
|
if value is None:
|
||||||
|
value = ""
|
||||||
|
|
||||||
|
if not isinstance(value, str):
|
||||||
|
frappe.throw(
|
||||||
|
_("Invalid value for {0}").format(fieldname)
|
||||||
|
)
|
||||||
|
|
||||||
|
if fieldname == "delivery_date":
|
||||||
|
doc.set(
|
||||||
|
fieldname,
|
||||||
|
getdate(value) if value else None,
|
||||||
|
)
|
||||||
|
continue
|
||||||
|
|
||||||
|
if fieldname == "free_text":
|
||||||
|
if len(value) > 10000:
|
||||||
|
frappe.throw(_("Free text is too long"))
|
||||||
|
|
||||||
|
doc.set(fieldname, sanitize_html(value))
|
||||||
|
continue
|
||||||
|
|
||||||
|
if len(value) > 500:
|
||||||
|
frappe.throw(
|
||||||
|
_("Text value is too long for {0}").format(
|
||||||
|
fieldname
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
doc.set(fieldname, value)
|
||||||
|
|
||||||
|
return doc
|
||||||
|
|
||||||
|
|
||||||
|
def _page_settings(config):
|
||||||
|
return {
|
||||||
|
"pdf_page_size": "Custom",
|
||||||
|
"pdf_page_width": config["width"],
|
||||||
|
"pdf_page_height": config["height"],
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@frappe.whitelist()
|
||||||
|
def preview_html(label_type, values=None):
|
||||||
|
"""Render translated HTML for the composer without Chromium."""
|
||||||
|
|
||||||
|
_require_login()
|
||||||
|
|
||||||
|
values = _parse_values(values)
|
||||||
|
language = _get_print_language(values)
|
||||||
|
|
||||||
|
config, error = _get_configuration(label_type)
|
||||||
|
|
||||||
|
if error:
|
||||||
|
return {"ready": False, "message": error}
|
||||||
|
|
||||||
|
print_format = config["print_format"]
|
||||||
|
|
||||||
|
if not print_format.custom_format:
|
||||||
|
return {
|
||||||
|
"ready": False,
|
||||||
|
"message": _(
|
||||||
|
"Live HTML preview requires an HTML/Jinja Print Format"
|
||||||
|
),
|
||||||
|
}
|
||||||
|
|
||||||
|
doc = _prepare_document(
|
||||||
|
config["template"],
|
||||||
|
label_type,
|
||||||
|
values,
|
||||||
|
)
|
||||||
|
|
||||||
|
settings = _page_settings(config)
|
||||||
|
|
||||||
|
with print_language(language):
|
||||||
|
html = get_rendered_template(
|
||||||
|
doc,
|
||||||
|
print_format=print_format,
|
||||||
|
no_letterhead=True,
|
||||||
|
settings=settings,
|
||||||
|
)
|
||||||
|
|
||||||
|
css = get_print_style(
|
||||||
|
print_format=print_format,
|
||||||
|
overrides=settings,
|
||||||
|
)
|
||||||
|
|
||||||
|
return {
|
||||||
|
"ready": True,
|
||||||
|
"html": html,
|
||||||
|
"css": css,
|
||||||
|
"language": language,
|
||||||
|
"printer": config["printer"].name,
|
||||||
|
"print_format": print_format.name,
|
||||||
|
"width_mm": config["width"],
|
||||||
|
"height_mm": config["height"],
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
def _render_pdf(label_type, values, config=None):
|
||||||
|
"""Render the print PDF in the same language as the HTML preview."""
|
||||||
|
|
||||||
|
values = _parse_values(values)
|
||||||
|
language = _get_print_language(values)
|
||||||
|
|
||||||
|
if config is None:
|
||||||
|
config, error = _get_configuration(label_type)
|
||||||
|
|
||||||
|
if error:
|
||||||
|
return None, config, error
|
||||||
|
|
||||||
|
doc = _prepare_document(
|
||||||
|
config["template"],
|
||||||
|
label_type,
|
||||||
|
values,
|
||||||
|
)
|
||||||
|
|
||||||
|
width = config["width"]
|
||||||
|
height = config["height"]
|
||||||
|
|
||||||
|
with print_language(language):
|
||||||
|
pdf = frappe.get_print(
|
||||||
|
doctype=TEMPLATE_DOCTYPE,
|
||||||
|
name=config["template"].name,
|
||||||
|
print_format=config["print_format"].name,
|
||||||
|
doc=doc,
|
||||||
|
as_pdf=True,
|
||||||
|
no_letterhead=1,
|
||||||
|
pdf_generator="chrome",
|
||||||
|
settings=_page_settings(config),
|
||||||
|
pdf_options={
|
||||||
|
"page-size": "Custom",
|
||||||
|
"page-width": f"{width}mm",
|
||||||
|
"page-height": f"{height}mm",
|
||||||
|
"margin-top": "0mm",
|
||||||
|
"margin-bottom": "0mm",
|
||||||
|
"margin-left": "0mm",
|
||||||
|
"margin-right": "0mm",
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
|
if not isinstance(pdf, bytes) or not pdf:
|
||||||
|
frappe.throw(_("PDF rendering returned no data"))
|
||||||
|
|
||||||
|
return pdf, config, None
|
||||||
|
|
||||||
|
|
||||||
|
@frappe.whitelist()
|
||||||
|
def preview_label(label_type, values=None):
|
||||||
|
"""Optional PDF diagnostic endpoint."""
|
||||||
|
|
||||||
|
_require_login()
|
||||||
|
|
||||||
|
pdf, config, error = _render_pdf(label_type, values)
|
||||||
|
|
||||||
|
if error:
|
||||||
|
return {"ready": False, "message": error}
|
||||||
|
|
||||||
|
reader = PdfReader(BytesIO(pdf))
|
||||||
|
|
||||||
|
if not reader.pages:
|
||||||
|
frappe.throw(_("The PDF contains no pages"))
|
||||||
|
|
||||||
|
page = reader.pages[0]
|
||||||
|
|
||||||
|
actual_width = float(page.mediabox.width) * 25.4 / 72
|
||||||
|
actual_height = float(page.mediabox.height) * 25.4 / 72
|
||||||
|
|
||||||
|
return {
|
||||||
|
"ready": True,
|
||||||
|
"pdf_base64": base64.b64encode(pdf).decode("ascii"),
|
||||||
|
"page_count": len(reader.pages),
|
||||||
|
"printer": config["printer"].name,
|
||||||
|
"print_format": config["print_format"].name,
|
||||||
|
"width_mm": config["width"],
|
||||||
|
"height_mm": config["height"],
|
||||||
|
"rendered_width_mm": round(actual_width, 2),
|
||||||
|
"rendered_height_mm": round(actual_height, 2),
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
# =============================================================
|
||||||
|
# CUPS printing
|
||||||
|
# =============================================================
|
||||||
|
|
||||||
|
def _validate_print_jobs(jobs):
|
||||||
|
jobs = frappe.parse_json(jobs)
|
||||||
|
|
||||||
|
if not isinstance(jobs, list) or not jobs:
|
||||||
|
frappe.throw(_("The print job is empty"))
|
||||||
|
|
||||||
|
if len(jobs) > MAX_GROUPS:
|
||||||
|
frappe.throw(
|
||||||
|
_("Too many print groups (maximum {0})").format(
|
||||||
|
MAX_GROUPS
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
validated = []
|
||||||
|
total_labels = 0
|
||||||
|
|
||||||
|
for index, job in enumerate(jobs, start=1):
|
||||||
|
if not isinstance(job, dict):
|
||||||
|
frappe.throw(
|
||||||
|
_("Invalid print group {0}").format(index)
|
||||||
|
)
|
||||||
|
|
||||||
|
label_type = job.get("label_type")
|
||||||
|
|
||||||
|
if label_type not in LABEL_FIELDS:
|
||||||
|
frappe.throw(
|
||||||
|
_("Invalid label type in group {0}").format(index)
|
||||||
|
)
|
||||||
|
|
||||||
|
values = job.get("values")
|
||||||
|
|
||||||
|
if not isinstance(values, dict):
|
||||||
|
frappe.throw(
|
||||||
|
_("Invalid label values in group {0}").format(index)
|
||||||
|
)
|
||||||
|
|
||||||
|
# This validates the language before any CUPS submission.
|
||||||
|
_get_print_language(values)
|
||||||
|
|
||||||
|
copies = job.get("copies")
|
||||||
|
|
||||||
|
if (
|
||||||
|
isinstance(copies, bool)
|
||||||
|
or not isinstance(copies, int)
|
||||||
|
or not 1 <= copies <= MAX_COPIES_PER_GROUP
|
||||||
|
):
|
||||||
|
frappe.throw(
|
||||||
|
_("Invalid copy count in group {0}").format(index)
|
||||||
|
)
|
||||||
|
|
||||||
|
total_labels += copies
|
||||||
|
|
||||||
|
if total_labels > MAX_TOTAL_LABELS:
|
||||||
|
frappe.throw(
|
||||||
|
_("Too many labels (maximum {0})").format(
|
||||||
|
MAX_TOTAL_LABELS
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
validated.append({
|
||||||
|
"label_type": label_type,
|
||||||
|
"values": values,
|
||||||
|
"copies": copies,
|
||||||
|
})
|
||||||
|
|
||||||
|
return validated, total_labels
|
||||||
|
|
||||||
|
|
||||||
|
def _cups_connection(cups, printer, connections):
|
||||||
|
"""Resolve the configured CUPS server and printer queue."""
|
||||||
|
|
||||||
|
host = str(printer.server_ip or "").strip()
|
||||||
|
|
||||||
|
if not host:
|
||||||
|
frappe.throw(
|
||||||
|
_("CUPS server address is missing for printer {0}").format(
|
||||||
|
printer.name
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
try:
|
||||||
|
port = int(printer.port or 631)
|
||||||
|
except (TypeError, ValueError):
|
||||||
|
frappe.throw(_("Invalid CUPS port"))
|
||||||
|
|
||||||
|
if not 1 <= port <= 65535:
|
||||||
|
frappe.throw(_("Invalid CUPS port"))
|
||||||
|
|
||||||
|
queue = str(printer.printer_name or "").strip()
|
||||||
|
|
||||||
|
if not queue:
|
||||||
|
frappe.throw(
|
||||||
|
_("CUPS queue name is missing for printer {0}").format(
|
||||||
|
printer.name
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
key = (host, port)
|
||||||
|
|
||||||
|
if key not in connections:
|
||||||
|
try:
|
||||||
|
connection = cups.Connection(host=host, port=port)
|
||||||
|
available = connection.getPrinters()
|
||||||
|
except (cups.IPPError, OSError) as exc:
|
||||||
|
frappe.throw(
|
||||||
|
_("Cannot connect to CUPS server for {0}: {1}").format(
|
||||||
|
printer.name,
|
||||||
|
str(exc),
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
connections[key] = {
|
||||||
|
"connection": connection,
|
||||||
|
"printers": available,
|
||||||
|
}
|
||||||
|
|
||||||
|
entry = connections[key]
|
||||||
|
|
||||||
|
if queue not in entry["printers"]:
|
||||||
|
frappe.throw(
|
||||||
|
_("CUPS printer queue {0} was not found").format(queue)
|
||||||
|
)
|
||||||
|
|
||||||
|
attributes = entry["printers"][queue]
|
||||||
|
|
||||||
|
if attributes.get("printer-is-accepting-jobs") is False:
|
||||||
|
frappe.throw(
|
||||||
|
_("CUPS printer {0} is not accepting jobs").format(queue)
|
||||||
|
)
|
||||||
|
|
||||||
|
return entry["connection"], queue
|
||||||
|
|
||||||
|
|
||||||
|
@frappe.whitelist()
|
||||||
|
def print_labels(jobs, allow_multipage=0):
|
||||||
|
"""Preflight all groups, then submit them to CUPS.
|
||||||
|
|
||||||
|
A successful response confirms queue acceptance, not completed
|
||||||
|
physical printing. Multiple CUPS submissions are not atomic.
|
||||||
|
"""
|
||||||
|
|
||||||
|
_require_login()
|
||||||
|
|
||||||
|
validated_jobs, total_labels = _validate_print_jobs(jobs)
|
||||||
|
|
||||||
|
try:
|
||||||
|
import cups
|
||||||
|
except ImportError:
|
||||||
|
frappe.throw(
|
||||||
|
_("pycups is not installed on the Frappe server")
|
||||||
|
)
|
||||||
|
|
||||||
|
connections = {}
|
||||||
|
prepared = []
|
||||||
|
|
||||||
|
# Stage 1: Validate all configurations and destinations.
|
||||||
|
for index, job in enumerate(validated_jobs, start=1):
|
||||||
|
config, error = _get_configuration(job["label_type"])
|
||||||
|
|
||||||
|
if error:
|
||||||
|
frappe.throw(
|
||||||
|
_("Group {0}: {1}").format(index, error)
|
||||||
|
)
|
||||||
|
|
||||||
|
connection, queue = _cups_connection(
|
||||||
|
cups,
|
||||||
|
config["printer"],
|
||||||
|
connections,
|
||||||
|
)
|
||||||
|
|
||||||
|
prepared.append({
|
||||||
|
"index": index,
|
||||||
|
"job": job,
|
||||||
|
"config": config,
|
||||||
|
"connection": connection,
|
||||||
|
"queue": queue,
|
||||||
|
})
|
||||||
|
|
||||||
|
# Stage 2: Render and inspect all PDFs before printing.
|
||||||
|
multipage_groups = []
|
||||||
|
|
||||||
|
for entry in prepared:
|
||||||
|
job = entry["job"]
|
||||||
|
|
||||||
|
pdf, _, error = _render_pdf(
|
||||||
|
job["label_type"],
|
||||||
|
job["values"],
|
||||||
|
config=entry["config"],
|
||||||
|
)
|
||||||
|
|
||||||
|
if error:
|
||||||
|
frappe.throw(
|
||||||
|
_("Group {0}: {1}").format(
|
||||||
|
entry["index"],
|
||||||
|
error,
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
pages = len(PdfReader(BytesIO(pdf)).pages)
|
||||||
|
|
||||||
|
if pages < 1:
|
||||||
|
frappe.throw(
|
||||||
|
_("Group {0} generated an empty PDF").format(
|
||||||
|
entry["index"]
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
entry["pdf"] = pdf
|
||||||
|
entry["pages"] = pages
|
||||||
|
|
||||||
|
if pages > 1:
|
||||||
|
multipage_groups.append({
|
||||||
|
"group": entry["index"],
|
||||||
|
"label_type": job["label_type"],
|
||||||
|
"printer": entry["config"]["printer"].name,
|
||||||
|
"copies": job["copies"],
|
||||||
|
"pages_per_copy": pages,
|
||||||
|
})
|
||||||
|
|
||||||
|
if multipage_groups and not cint(allow_multipage):
|
||||||
|
return {
|
||||||
|
"status": "multipage_warning",
|
||||||
|
"total_labels": total_labels,
|
||||||
|
"multipage_groups": multipage_groups,
|
||||||
|
}
|
||||||
|
|
||||||
|
# Stage 3: Submit all prepared PDFs in group order.
|
||||||
|
submitted = []
|
||||||
|
|
||||||
|
for entry in prepared:
|
||||||
|
path = None
|
||||||
|
|
||||||
|
try:
|
||||||
|
with tempfile.NamedTemporaryFile(
|
||||||
|
mode="wb",
|
||||||
|
prefix="label-composer-",
|
||||||
|
suffix=".pdf",
|
||||||
|
delete=False,
|
||||||
|
) as file:
|
||||||
|
file.write(entry["pdf"])
|
||||||
|
path = file.name
|
||||||
|
|
||||||
|
job = entry["job"]
|
||||||
|
|
||||||
|
options = {
|
||||||
|
"copies": str(job["copies"]),
|
||||||
|
"job-sheets": "none",
|
||||||
|
"sides": "one-sided",
|
||||||
|
}
|
||||||
|
|
||||||
|
title = (
|
||||||
|
f"Label Composer - {job['label_type']} "
|
||||||
|
f"- Group {entry['index']}"
|
||||||
|
)
|
||||||
|
|
||||||
|
cups_job_id = entry["connection"].printFile(
|
||||||
|
entry["queue"],
|
||||||
|
path,
|
||||||
|
title,
|
||||||
|
options,
|
||||||
|
)
|
||||||
|
|
||||||
|
submitted.append({
|
||||||
|
"group": entry["index"],
|
||||||
|
"label_type": job["label_type"],
|
||||||
|
"printer": entry["config"]["printer"].name,
|
||||||
|
"queue": entry["queue"],
|
||||||
|
"cups_job_id": cups_job_id,
|
||||||
|
"copies": job["copies"],
|
||||||
|
"pages_per_copy": entry["pages"],
|
||||||
|
})
|
||||||
|
|
||||||
|
except (cups.IPPError, OSError) as exc:
|
||||||
|
frappe.log_error(
|
||||||
|
title="Label Composer CUPS submission failed",
|
||||||
|
message=frappe.get_traceback(),
|
||||||
|
)
|
||||||
|
|
||||||
|
return {
|
||||||
|
"status": "partial_failure",
|
||||||
|
"submitted": submitted,
|
||||||
|
"failed_group": entry["index"],
|
||||||
|
"message": str(exc),
|
||||||
|
"retry_warning": _(
|
||||||
|
"Check the CUPS queue before trying again. "
|
||||||
|
"Some labels may already have been submitted."
|
||||||
|
),
|
||||||
|
}
|
||||||
|
|
||||||
|
finally:
|
||||||
|
if path and os.path.exists(path):
|
||||||
|
os.unlink(path)
|
||||||
|
|
||||||
|
return {
|
||||||
|
"status": "submitted",
|
||||||
|
"submitted": submitted,
|
||||||
|
"total_groups": len(submitted),
|
||||||
|
"total_labels": total_labels,
|
||||||
|
}
|
||||||
File renamed without changes.
Whitespace-only changes.
+8
@@ -0,0 +1,8 @@
|
|||||||
|
// Copyright (c) 2026, CAnetzberger Design and contributors
|
||||||
|
// For license information, please see license.txt
|
||||||
|
|
||||||
|
// frappe.ui.form.on("Label Composer Template", {
|
||||||
|
// refresh(frm) {
|
||||||
|
|
||||||
|
// },
|
||||||
|
// });
|
||||||
+144
@@ -0,0 +1,144 @@
|
|||||||
|
{
|
||||||
|
"actions": [],
|
||||||
|
"allow_bulk_edit": 1,
|
||||||
|
"allow_rename": 1,
|
||||||
|
"autoname": "field:template_name",
|
||||||
|
"creation": "2026-10-25 17:08:31.393480",
|
||||||
|
"doctype": "DocType",
|
||||||
|
"engine": "InnoDB",
|
||||||
|
"field_order": [
|
||||||
|
"generic_section",
|
||||||
|
"template_name",
|
||||||
|
"label_type",
|
||||||
|
"enabled",
|
||||||
|
"column_break_mcpv",
|
||||||
|
"default_printer",
|
||||||
|
"print_format",
|
||||||
|
"preview_data_section",
|
||||||
|
"delivery_date_column",
|
||||||
|
"customer",
|
||||||
|
"supplier",
|
||||||
|
"item_code",
|
||||||
|
"item_name",
|
||||||
|
"quantity",
|
||||||
|
"delivery_date",
|
||||||
|
"free_text"
|
||||||
|
],
|
||||||
|
"fields": [
|
||||||
|
{
|
||||||
|
"fieldname": "generic_section",
|
||||||
|
"fieldtype": "Section Break",
|
||||||
|
"label": "Generic"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "label_type",
|
||||||
|
"fieldtype": "Select",
|
||||||
|
"label": "Label Type",
|
||||||
|
"options": "Customer Label\nWarehouse Label\nSupplier Label\nGeneric Label"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"default": "1",
|
||||||
|
"fieldname": "enabled",
|
||||||
|
"fieldtype": "Check",
|
||||||
|
"label": "Enabled"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "column_break_mcpv",
|
||||||
|
"fieldtype": "Column Break"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "default_printer",
|
||||||
|
"fieldtype": "Link",
|
||||||
|
"label": "Default Printer",
|
||||||
|
"options": "Network Printer Settings"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "print_format",
|
||||||
|
"fieldtype": "Link",
|
||||||
|
"label": "Print Format",
|
||||||
|
"options": "Print Format"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "preview_data_section",
|
||||||
|
"fieldtype": "Section Break",
|
||||||
|
"label": "Preview Data"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "delivery_date_column",
|
||||||
|
"fieldtype": "Column Break",
|
||||||
|
"label": "Delivery Date"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "customer",
|
||||||
|
"fieldtype": "Data",
|
||||||
|
"label": "Customer"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "supplier",
|
||||||
|
"fieldtype": "Data",
|
||||||
|
"label": "Supplier"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "item_code",
|
||||||
|
"fieldtype": "Data",
|
||||||
|
"label": "Item Code"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "item_name",
|
||||||
|
"fieldtype": "Data",
|
||||||
|
"label": "Item Name"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "quantity",
|
||||||
|
"fieldtype": "Float",
|
||||||
|
"label": "Quantity",
|
||||||
|
"precision": "0"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "delivery_date",
|
||||||
|
"fieldtype": "Date",
|
||||||
|
"label": "Delivery Date"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "free_text",
|
||||||
|
"fieldtype": "Text Editor",
|
||||||
|
"label": "Free Text"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "template_name",
|
||||||
|
"fieldtype": "Data",
|
||||||
|
"in_list_view": 1,
|
||||||
|
"label": "Template Name",
|
||||||
|
"reqd": 1,
|
||||||
|
"unique": 1
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"grid_page_length": 50,
|
||||||
|
"index_web_pages_for_search": 1,
|
||||||
|
"links": [],
|
||||||
|
"modified": "2026-10-25 17:28:48.739473",
|
||||||
|
"modified_by": "Administrator",
|
||||||
|
"module": "Label Composer",
|
||||||
|
"name": "Label Composer Template",
|
||||||
|
"naming_rule": "By fieldname",
|
||||||
|
"owner": "Administrator",
|
||||||
|
"permissions": [
|
||||||
|
{
|
||||||
|
"create": 1,
|
||||||
|
"delete": 1,
|
||||||
|
"email": 1,
|
||||||
|
"export": 1,
|
||||||
|
"print": 1,
|
||||||
|
"read": 1,
|
||||||
|
"report": 1,
|
||||||
|
"role": "System Manager",
|
||||||
|
"share": 1,
|
||||||
|
"write": 1
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"row_format": "Dynamic",
|
||||||
|
"rows_threshold_for_grid_search": 20,
|
||||||
|
"sort_field": "creation",
|
||||||
|
"sort_order": "DESC",
|
||||||
|
"states": []
|
||||||
|
}
|
||||||
+9
@@ -0,0 +1,9 @@
|
|||||||
|
# Copyright (c) 2026, CAnetzberger Design and contributors
|
||||||
|
# For license information, please see license.txt
|
||||||
|
|
||||||
|
# import frappe
|
||||||
|
from frappe.model.document import Document
|
||||||
|
|
||||||
|
|
||||||
|
class LabelComposerTemplate(Document):
|
||||||
|
pass
|
||||||
+22
@@ -0,0 +1,22 @@
|
|||||||
|
# Copyright (c) 2026, CAnetzberger Design and Contributors
|
||||||
|
# See license.txt
|
||||||
|
|
||||||
|
# import frappe
|
||||||
|
from frappe.tests import IntegrationTestCase
|
||||||
|
|
||||||
|
|
||||||
|
# On IntegrationTestCase, the doctype test records and all
|
||||||
|
# link-field test record dependencies are recursively loaded
|
||||||
|
# Use these module variables to add/remove to/from that list
|
||||||
|
EXTRA_TEST_RECORD_DEPENDENCIES = [] # eg. ["User"]
|
||||||
|
IGNORE_TEST_RECORD_DEPENDENCIES = [] # eg. ["User"]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class IntegrationTestLabelComposerTemplate(IntegrationTestCase):
|
||||||
|
"""
|
||||||
|
Integration tests for LabelComposerTemplate.
|
||||||
|
Use this class for testing interactions between multiple components.
|
||||||
|
"""
|
||||||
|
|
||||||
|
pass
|
||||||
@@ -1 +1,2 @@
|
|||||||
Manufacturing Overview
|
Manufacturing Overview
|
||||||
|
Label Composer
|
||||||
@@ -0,0 +1,502 @@
|
|||||||
|
/* =========================================================
|
||||||
|
Manufacturing Utilities — Label Composer
|
||||||
|
========================================================= */
|
||||||
|
|
||||||
|
/* ---------------------------------------------------------
|
||||||
|
Native Dock Utility
|
||||||
|
--------------------------------------------------------- */
|
||||||
|
|
||||||
|
.dock-utilities .lc-dock-utility {
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
.dock-utilities .lc-dock-utility .dock-item-icon {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ---------------------------------------------------------
|
||||||
|
Floating Desktop Fallback
|
||||||
|
--------------------------------------------------------- */
|
||||||
|
|
||||||
|
.lc-launcher--floating {
|
||||||
|
position: fixed;
|
||||||
|
right: 24px;
|
||||||
|
bottom: 24px;
|
||||||
|
z-index: 1020;
|
||||||
|
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
gap: 9px;
|
||||||
|
|
||||||
|
min-height: 42px;
|
||||||
|
padding: 11px 17px;
|
||||||
|
|
||||||
|
border: 1px solid var(--border-color);
|
||||||
|
border-radius: 12px;
|
||||||
|
|
||||||
|
background: var(--card-bg);
|
||||||
|
color: var(--text-color);
|
||||||
|
|
||||||
|
font-size: 13px;
|
||||||
|
font-weight: 600;
|
||||||
|
cursor: pointer;
|
||||||
|
box-shadow: var(--shadow-lg);
|
||||||
|
|
||||||
|
transition:
|
||||||
|
background 0.15s ease,
|
||||||
|
transform 0.15s ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
.lc-launcher--floating:hover {
|
||||||
|
background: var(--control-bg);
|
||||||
|
transform: translateY(-2px);
|
||||||
|
}
|
||||||
|
|
||||||
|
.lc-launcher--floating:focus-visible {
|
||||||
|
outline: 2px solid var(--primary);
|
||||||
|
outline-offset: 3px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.lc-launcher-icon {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.lc-launcher-icon svg {
|
||||||
|
width: 18px;
|
||||||
|
height: 18px;
|
||||||
|
}
|
||||||
|
|
||||||
|
body:has(#desk-dock.dock-owns-utilities:not(.hidden)[aria-hidden="false"]) .lc-launcher--floating {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ---------------------------------------------------------
|
||||||
|
Modal Sizing
|
||||||
|
--------------------------------------------------------- */
|
||||||
|
|
||||||
|
.label-composer-dialog .modal-dialog {
|
||||||
|
width: min(1180px, calc(100vw - 48px));
|
||||||
|
max-width: 1180px;
|
||||||
|
margin: 24px auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.label-composer-dialog .modal-content {
|
||||||
|
max-height: calc(100dvh - 48px);
|
||||||
|
overflow: hidden;
|
||||||
|
border-radius: 14px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.label-composer-dialog .modal-header {
|
||||||
|
flex-shrink: 0;
|
||||||
|
padding: 16px 22px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.label-composer-dialog .modal-body {
|
||||||
|
min-height: 0;
|
||||||
|
overflow-y: auto;
|
||||||
|
padding: 20px 24px 22px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.label-composer-dialog .modal-footer {
|
||||||
|
flex-shrink: 0;
|
||||||
|
padding: 12px 22px;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ---------------------------------------------------------
|
||||||
|
Native Two-Column Frappe Section
|
||||||
|
--------------------------------------------------------- */
|
||||||
|
|
||||||
|
.label-composer-dialog .lc-composer-section > .section-body {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns:
|
||||||
|
minmax(0, 0.95fr)
|
||||||
|
minmax(0, 1.05fr);
|
||||||
|
align-items: start;
|
||||||
|
gap: 28px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.label-composer-dialog .lc-composer-section > .section-body > .form-column {
|
||||||
|
float: none !important;
|
||||||
|
width: auto !important;
|
||||||
|
max-width: none !important;
|
||||||
|
min-width: 0;
|
||||||
|
padding: 0 !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.label-composer-dialog .lc-fields-column {
|
||||||
|
padding-right: 8px !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.label-composer-dialog .lc-preview-column {
|
||||||
|
align-self: start;
|
||||||
|
position: sticky;
|
||||||
|
top: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.label-composer-dialog .lc-fields-column .frappe-control {
|
||||||
|
margin-bottom: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.label-composer-dialog .lc-fields-column .form-group {
|
||||||
|
margin-bottom: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.label-composer-dialog .lc-fields-column .control-label {
|
||||||
|
font-size: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.label-composer-dialog .lc-fields-column .form-control {
|
||||||
|
min-height: 34px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.label-composer-dialog .lc-fields-column .checkbox {
|
||||||
|
margin-top: 6px;
|
||||||
|
margin-bottom: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ---------------------------------------------------------
|
||||||
|
Document Context
|
||||||
|
--------------------------------------------------------- */
|
||||||
|
|
||||||
|
.lc-source-info {
|
||||||
|
display: flex;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
gap: 5px 8px;
|
||||||
|
align-items: baseline;
|
||||||
|
|
||||||
|
margin-bottom: 12px;
|
||||||
|
padding-bottom: 10px;
|
||||||
|
|
||||||
|
border-bottom: 1px solid var(--border-color);
|
||||||
|
|
||||||
|
color: var(--text-muted);
|
||||||
|
font-size: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.lc-source-info strong {
|
||||||
|
color: var(--text-color);
|
||||||
|
font-weight: 600;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ---------------------------------------------------------
|
||||||
|
Compact Packaging Quantity Editor
|
||||||
|
--------------------------------------------------------- */
|
||||||
|
|
||||||
|
.lc-quantity-editor {
|
||||||
|
margin: 8px 0 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.lc-qty-headings,
|
||||||
|
.lc-qty-row {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns:
|
||||||
|
minmax(0, 1.5fr)
|
||||||
|
minmax(0, 0.9fr)
|
||||||
|
34px;
|
||||||
|
align-items: center;
|
||||||
|
gap: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.lc-qty-headings {
|
||||||
|
margin-bottom: 6px;
|
||||||
|
color: var(--text-muted);
|
||||||
|
font-size: 11px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.lc-qty-row {
|
||||||
|
margin-bottom: 7px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.lc-qty-row .form-control {
|
||||||
|
width: 100%;
|
||||||
|
min-width: 0;
|
||||||
|
min-height: 34px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.lc-remove-group {
|
||||||
|
width: 34px;
|
||||||
|
height: 34px;
|
||||||
|
padding: 6px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.lc-add-group {
|
||||||
|
margin-top: 3px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.lc-quantity-summary {
|
||||||
|
display: flex;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
align-items: center;
|
||||||
|
gap: 6px 16px;
|
||||||
|
|
||||||
|
margin-top: 11px;
|
||||||
|
padding: 10px 12px;
|
||||||
|
|
||||||
|
border: 1px solid var(--border-color);
|
||||||
|
border-radius: 8px;
|
||||||
|
background: var(--control-bg);
|
||||||
|
|
||||||
|
font-size: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.lc-total-parts,
|
||||||
|
.lc-total-labels {
|
||||||
|
font-weight: 600;
|
||||||
|
}
|
||||||
|
|
||||||
|
.lc-reference-status {
|
||||||
|
flex-basis: 100%;
|
||||||
|
font-size: 11px;
|
||||||
|
color: var(--text-muted);
|
||||||
|
}
|
||||||
|
|
||||||
|
.lc-status-success {
|
||||||
|
color: var(--green-600, #16803c);
|
||||||
|
}
|
||||||
|
|
||||||
|
.lc-status-warning {
|
||||||
|
color: var(--orange-600, #a96500);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ---------------------------------------------------------
|
||||||
|
Right Preview Panel
|
||||||
|
--------------------------------------------------------- */
|
||||||
|
|
||||||
|
.lc-preview {
|
||||||
|
overflow: hidden;
|
||||||
|
|
||||||
|
border: 1px solid var(--border-color);
|
||||||
|
border-radius: 12px;
|
||||||
|
|
||||||
|
background: var(--card-bg);
|
||||||
|
}
|
||||||
|
|
||||||
|
.lc-preview-heading {
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
align-items: center;
|
||||||
|
gap: 12px;
|
||||||
|
|
||||||
|
padding: 16px 18px;
|
||||||
|
|
||||||
|
border-bottom: 1px solid var(--border-color);
|
||||||
|
}
|
||||||
|
|
||||||
|
.lc-preview-eyebrow {
|
||||||
|
margin-bottom: 4px;
|
||||||
|
|
||||||
|
color: var(--text-muted);
|
||||||
|
font-size: 10px;
|
||||||
|
font-weight: 600;
|
||||||
|
letter-spacing: 1px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.lc-selected-type {
|
||||||
|
font-size: 16px;
|
||||||
|
font-weight: 600;
|
||||||
|
color: var(--text-color);
|
||||||
|
}
|
||||||
|
|
||||||
|
.lc-preview-mode {
|
||||||
|
padding: 4px 8px;
|
||||||
|
|
||||||
|
border: 1px solid var(--border-color);
|
||||||
|
border-radius: 6px;
|
||||||
|
|
||||||
|
color: var(--text-muted);
|
||||||
|
font-size: 11px;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ---------------------------------------------------------
|
||||||
|
Preview Group Selector
|
||||||
|
--------------------------------------------------------- */
|
||||||
|
|
||||||
|
.lc-preview-jobs {
|
||||||
|
display: flex;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
gap: 7px;
|
||||||
|
|
||||||
|
padding: 14px 18px 4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.lc-preview-job {
|
||||||
|
border-radius: 8px;
|
||||||
|
font-size: 11px;
|
||||||
|
line-height: 1.4;
|
||||||
|
|
||||||
|
white-space: normal;
|
||||||
|
text-align: left;
|
||||||
|
}
|
||||||
|
|
||||||
|
.lc-preview-job-active {
|
||||||
|
background: var(--primary);
|
||||||
|
border: 1px solid var(--primary);
|
||||||
|
color: #ffffff;
|
||||||
|
}
|
||||||
|
|
||||||
|
.lc-preview-job-active:hover {
|
||||||
|
color: #ffffff;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ---------------------------------------------------------
|
||||||
|
Physical Label Preview
|
||||||
|
--------------------------------------------------------- */
|
||||||
|
|
||||||
|
.lc-preview-canvas {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
|
||||||
|
width: 100%;
|
||||||
|
min-height: 245px;
|
||||||
|
|
||||||
|
margin: 12px 0 0;
|
||||||
|
padding: 24px 14px;
|
||||||
|
|
||||||
|
background: var(--control-bg);
|
||||||
|
}
|
||||||
|
|
||||||
|
.lc-preview-sheet {
|
||||||
|
position: relative;
|
||||||
|
display: none;
|
||||||
|
flex-shrink: 0;
|
||||||
|
|
||||||
|
overflow: hidden;
|
||||||
|
|
||||||
|
border: 1px solid #d8d8d8;
|
||||||
|
border-radius: 2px;
|
||||||
|
|
||||||
|
background: #ffffff;
|
||||||
|
box-shadow:
|
||||||
|
0 2px 5px rgba(0, 0, 0, 0.07),
|
||||||
|
0 12px 26px rgba(0, 0, 0, 0.09);
|
||||||
|
}
|
||||||
|
|
||||||
|
.lc-html-frame {
|
||||||
|
position: absolute;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
|
||||||
|
display: none;
|
||||||
|
border: 0;
|
||||||
|
padding: 0;
|
||||||
|
margin: 0;
|
||||||
|
|
||||||
|
background: #ffffff;
|
||||||
|
|
||||||
|
/* The preview is visual only. */
|
||||||
|
pointer-events: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.lc-preview-message {
|
||||||
|
padding: 11px 18px 3px;
|
||||||
|
|
||||||
|
min-height: 32px;
|
||||||
|
color: var(--text-muted);
|
||||||
|
|
||||||
|
font-size: 12px;
|
||||||
|
line-height: 1.5;
|
||||||
|
}
|
||||||
|
|
||||||
|
.lc-preview-warning {
|
||||||
|
color: var(--orange-600, #a96500);
|
||||||
|
}
|
||||||
|
|
||||||
|
.lc-preview-error {
|
||||||
|
color: var(--red-600, #c53030);
|
||||||
|
}
|
||||||
|
|
||||||
|
.lc-preview-details {
|
||||||
|
padding: 0 18px 14px;
|
||||||
|
|
||||||
|
color: var(--text-muted);
|
||||||
|
font-size: 11px;
|
||||||
|
line-height: 1.5;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ---------------------------------------------------------
|
||||||
|
Print Job Summary
|
||||||
|
--------------------------------------------------------- */
|
||||||
|
|
||||||
|
.lc-preview-bottom {
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
align-items: center;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
gap: 8px;
|
||||||
|
|
||||||
|
padding: 13px 18px;
|
||||||
|
|
||||||
|
border-top: 1px solid var(--border-color);
|
||||||
|
|
||||||
|
font-size: 12px;
|
||||||
|
color: var(--text-muted);
|
||||||
|
}
|
||||||
|
|
||||||
|
.lc-job-summary {
|
||||||
|
color: var(--text-color);
|
||||||
|
font-size: 12px;
|
||||||
|
font-weight: 600;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ---------------------------------------------------------
|
||||||
|
Responsive
|
||||||
|
--------------------------------------------------------- */
|
||||||
|
|
||||||
|
@media (max-width: 900px) {
|
||||||
|
.label-composer-dialog .modal-dialog {
|
||||||
|
width: calc(100vw - 24px);
|
||||||
|
margin: 12px auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.label-composer-dialog .modal-content {
|
||||||
|
max-height: calc(100dvh - 24px);
|
||||||
|
}
|
||||||
|
|
||||||
|
.label-composer-dialog .lc-composer-section > .section-body {
|
||||||
|
grid-template-columns: minmax(0, 1fr);
|
||||||
|
gap: 18px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.label-composer-dialog .lc-preview-column {
|
||||||
|
position: static;
|
||||||
|
}
|
||||||
|
|
||||||
|
.label-composer-dialog .modal-body {
|
||||||
|
padding: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.lc-preview-canvas {
|
||||||
|
min-height: 200px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (max-width: 600px) {
|
||||||
|
.lc-launcher--floating {
|
||||||
|
right: 16px;
|
||||||
|
bottom: 16px;
|
||||||
|
padding: 11px 13px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.lc-launcher--floating .lc-launcher-label {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.lc-preview-heading {
|
||||||
|
padding: 12px 14px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.lc-preview-jobs {
|
||||||
|
padding: 12px 14px 4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.lc-preview-canvas {
|
||||||
|
min-height: 175px;
|
||||||
|
padding: 14px 8px;
|
||||||
|
}
|
||||||
|
}
|
||||||
File diff suppressed because it is too large.
Load diff
Reference in new issue
Block a user