diff --git a/label_printing/hooks.py b/label_printing/hooks.py
index 0a2c6bc..91e4f1f 100644
--- a/label_printing/hooks.py
+++ b/label_printing/hooks.py
@@ -14,7 +14,7 @@ app_license = "MIT"
# include js, css files in header of desk.html
# app_include_css = "/assets/label_printing/css/label_printing.css"
-# app_include_js = "/assets/label_printing/js/label_printing.js"
+app_include_js = "/assets/label_printing/js/label_printing.min.js"
# include js, css files in header of web template
# web_include_css = "/assets/label_printing/css/label_printing.css"
@@ -152,24 +152,24 @@ app_license = "MIT"
# --------------------
user_data_fields = [
- {
- "doctype": "{doctype_1}",
- "filter_by": "{filter_by}",
- "redact_fields": ["{field_1}", "{field_2}"],
- "partial": 1,
- },
- {
- "doctype": "{doctype_2}",
- "filter_by": "{filter_by}",
- "partial": 1,
- },
- {
- "doctype": "{doctype_3}",
- "strict": False,
- },
- {
- "doctype": "{doctype_4}"
- }
+ {
+ "doctype": "{doctype_1}",
+ "filter_by": "{filter_by}",
+ "redact_fields": ["{field_1}", "{field_2}"],
+ "partial": 1,
+ },
+ {
+ "doctype": "{doctype_2}",
+ "filter_by": "{filter_by}",
+ "partial": 1,
+ },
+ {
+ "doctype": "{doctype_3}",
+ "strict": False,
+ },
+ {
+ "doctype": "{doctype_4}"
+ }
]
# Authentication and authorization
@@ -178,4 +178,3 @@ user_data_fields = [
# auth_hooks = [
# "label_printing.auth.validate"
# ]
-
diff --git a/label_printing/label_printing/api.py b/label_printing/label_printing/api.py
new file mode 100644
index 0000000..6d0380f
--- /dev/null
+++ b/label_printing/label_printing/api.py
@@ -0,0 +1,7 @@
+import frappe
+
+
+@frappe.whitelist()
+def create_labels(values):
+ print(values)
+ return 200
diff --git a/label_printing/label_printing/doctype/__init__.py b/label_printing/label_printing/doctype/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/label_printing/label_printing/doctype/labels/__init__.py b/label_printing/label_printing/doctype/labels/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/label_printing/label_printing/doctype/labels/labels.js b/label_printing/label_printing/doctype/labels/labels.js
new file mode 100644
index 0000000..e29fdb8
--- /dev/null
+++ b/label_printing/label_printing/doctype/labels/labels.js
@@ -0,0 +1,8 @@
+// Copyright (c) 2022, CAnetzberger Design and contributors
+// For license information, please see license.txt
+
+frappe.ui.form.on('Labels', {
+ // refresh: function(frm) {
+
+ // }
+});
diff --git a/label_printing/label_printing/doctype/labels/labels.json b/label_printing/label_printing/doctype/labels/labels.json
new file mode 100644
index 0000000..b5269da
--- /dev/null
+++ b/label_printing/label_printing/doctype/labels/labels.json
@@ -0,0 +1,95 @@
+{
+ "actions": [],
+ "autoname": "Label-.#####",
+ "creation": "2022-01-19 11:12:23.234541",
+ "doctype": "DocType",
+ "editable_grid": 1,
+ "engine": "InnoDB",
+ "field_order": [
+ "label_information_section",
+ "item_code",
+ "item_name",
+ "qty",
+ "column_break_4",
+ "delivery_date",
+ "customer",
+ "batch"
+ ],
+ "fields": [
+ {
+ "fieldname": "item_code",
+ "fieldtype": "Data",
+ "label": "Item Code"
+ },
+ {
+ "fieldname": "item_name",
+ "fieldtype": "Data",
+ "label": "Item Name"
+ },
+ {
+ "fieldname": "delivery_date",
+ "fieldtype": "Date",
+ "label": "Delivery Date"
+ },
+ {
+ "fieldname": "customer",
+ "fieldtype": "Data",
+ "label": "Customer"
+ },
+ {
+ "fieldname": "batch",
+ "fieldtype": "Data",
+ "label": "Batch"
+ },
+ {
+ "fieldname": "label_information_section",
+ "fieldtype": "Section Break",
+ "label": "Label Information"
+ },
+ {
+ "fieldname": "column_break_4",
+ "fieldtype": "Column Break"
+ },
+ {
+ "fieldname": "qty",
+ "fieldtype": "Int",
+ "label": "Quantity"
+ }
+ ],
+ "icon": "fa fa-tag",
+ "links": [],
+ "modified": "2022-01-19 12:08:40.613669",
+ "modified_by": "Administrator",
+ "module": "Label Printing",
+ "name": "Labels",
+ "name_case": "UPPER CASE",
+ "owner": "Administrator",
+ "permissions": [
+ {
+ "create": 1,
+ "delete": 1,
+ "email": 1,
+ "export": 1,
+ "print": 1,
+ "read": 1,
+ "report": 1,
+ "role": "System Manager",
+ "share": 1,
+ "write": 1
+ },
+ {
+ "create": 1,
+ "delete": 1,
+ "email": 1,
+ "export": 1,
+ "print": 1,
+ "read": 1,
+ "report": 1,
+ "role": "Employee",
+ "share": 1,
+ "write": 1
+ }
+ ],
+ "sort_field": "modified",
+ "sort_order": "DESC"
+}
\ No newline at end of file
diff --git a/label_printing/label_printing/doctype/labels/labels.py b/label_printing/label_printing/doctype/labels/labels.py
new file mode 100644
index 0000000..c3119f4
--- /dev/null
+++ b/label_printing/label_printing/doctype/labels/labels.py
@@ -0,0 +1,8 @@
+# Copyright (c) 2022, CAnetzberger Design and contributors
+# For license information, please see license.txt
+
+# import frappe
+from frappe.model.document import Document
+
+class Labels(Document):
+ pass
diff --git a/label_printing/label_printing/doctype/labels/test_labels.py b/label_printing/label_printing/doctype/labels/test_labels.py
new file mode 100644
index 0000000..ee70f3d
--- /dev/null
+++ b/label_printing/label_printing/doctype/labels/test_labels.py
@@ -0,0 +1,8 @@
+# Copyright (c) 2022, CAnetzberger Design and Contributors
+# See license.txt
+
+# import frappe
+import unittest
+
+class TestLabels(unittest.TestCase):
+ pass
diff --git a/label_printing/label_printing/print_format/__init__.py b/label_printing/label_printing/print_format/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/label_printing/label_printing/print_format/labels/__init__.py b/label_printing/label_printing/print_format/labels/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/label_printing/label_printing/print_format/labels/labels.json b/label_printing/label_printing/print_format/labels/labels.json
new file mode 100644
index 0000000..a3f268f
--- /dev/null
+++ b/label_printing/label_printing/print_format/labels/labels.json
@@ -0,0 +1,26 @@
+{
+ "absolute_value": 0,
+ "align_labels_right": 0,
+ "creation": "2022-01-19 11:21:57.395703",
+ "css": ".print-format {\n margin-top: 0;\n margin-left: 0;\n margin-right: 0;\n width: 110mm;\n height: 41mm;\n}",
+ "custom_format": 1,
+ "default_print_language": "de",
+ "disabled": 0,
+ "doc_type": "Labels",
+ "docstatus": 0,
+ "doctype": "Print Format",
+ "font": "Default",
+ "html": "
\n
\n
{{doc.item_code}}
\n
{{doc.item_name}}
\n {% if doc.customer %}\n
{{doc.customer}}
\n {% endif %}\n {% if doc.delivery_date %}\n
{{_(\"Delivery Date\")}}: {{frappe.utils.formatdate(doc.delivery_date, \"dd.MM.YYYY\")}}
\n {% endif %}\n {% if doc.batch %}\n
{{_(\"Batch\")}}: {{doc.batch}}
\n {% endif %}\n
\n
",
+ "idx": 0,
+ "line_breaks": 0,
+ "modified": "2022-01-19 11:55:11.454239",
+ "modified_by": "Administrator",
+ "module": "Label Printing",
+ "name": "Labels",
+ "owner": "Administrator",
+ "print_format_builder": 0,
+ "print_format_type": "Jinja",
+ "raw_printing": 0,
+ "show_section_headings": 0,
+ "standard": "Yes"
+}
\ No newline at end of file
diff --git a/label_printing/public/build.json b/label_printing/public/build.json
new file mode 100644
index 0000000..36d6cc2
--- /dev/null
+++ b/label_printing/public/build.json
@@ -0,0 +1,5 @@
+{
+ "label_printing/js/label_printing.min.js": [
+ "public/js/label_printing_desk.js"
+ ]
+}
\ No newline at end of file
diff --git a/label_printing/public/js/label_printing.min.js b/label_printing/public/js/label_printing.min.js
new file mode 100644
index 0000000..e0361de
--- /dev/null
+++ b/label_printing/public/js/label_printing.min.js
@@ -0,0 +1,396 @@
+(function () {
+ 'use strict';
+
+ //
+ //
+ //
+ //
+ //
+ //
+ //
+ //
+
+ var script = {
+ name: "LabelPrintingDialog",
+ props: [],
+ methods: {},
+ };
+
+ /* script */
+ var __vue_script__ = script;
+
+ /* template */
+ var __vue_render__ = function() {
+ var _vm = this;
+ var _h = _vm.$createElement;
+ var _c = _vm._self._c || _h;
+ return _vm._m(0)
+ };
+ var __vue_staticRenderFns__ = [
+ function() {
+ var _vm = this;
+ var _h = _vm.$createElement;
+ var _c = _vm._self._c || _h;
+ return _c("li", { staticClass: "nav-item" }, [
+ _c("a", { staticClass: "nav-link label-printing-icon text-muted" }, [
+ _c("i", {
+ staticClass: "fa fa-tag fa-lg",
+ attrs: { "aria-hidden": "true" }
+ })
+ ])
+ ])
+ }
+ ];
+ __vue_render__._withStripped = true;
+
+ /* style */
+ var __vue_inject_styles__ = function (inject) {
+ if (!inject) { return }
+ inject("data-v-0458d41e_0", { source: "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n", map: {"version":3,"sources":[],"names":[],"mappings":"","file":"label_printing_dialog.vue"}, media: undefined });
+
+ };
+ /* scoped */
+ var __vue_scope_id__ = undefined;
+ /* module identifier */
+ var __vue_module_identifier__ = undefined;
+ /* functional template */
+ var __vue_is_functional_template__ = false;
+ /* component normalizer */
+ function __vue_normalize__(
+ template, style, script,
+ scope, functional, moduleIdentifier,
+ createInjector, createInjectorSSR
+ ) {
+ var component = (typeof script === 'function' ? script.options : script) || {};
+
+ // For security concerns, we use only base name in production mode.
+ component.__file = "/Volumes/development/frappe/frappe-bench/apps/label_printing/label_printing/public/js/label_printing_dialog.vue";
+
+ if (!component.render) {
+ component.render = template.render;
+ component.staticRenderFns = template.staticRenderFns;
+ component._compiled = true;
+
+ if (functional) { component.functional = true; }
+ }
+
+ component._scopeId = scope;
+
+ {
+ var hook;
+ if (style) {
+ hook = function(context) {
+ style.call(this, createInjector(context));
+ };
+ }
+
+ if (hook !== undefined) {
+ if (component.functional) {
+ // register for functional component in vue file
+ var originalRender = component.render;
+ component.render = function renderWithStyleInjection(h, context) {
+ hook.call(context);
+ return originalRender(h, context)
+ };
+ } else {
+ // inject component registration as beforeCreate hook
+ var existing = component.beforeCreate;
+ component.beforeCreate = existing ? [].concat(existing, hook) : [hook];
+ }
+ }
+ }
+
+ return component
+ }
+ /* style inject */
+ function __vue_create_injector__() {
+ var head = document.head || document.getElementsByTagName('head')[0];
+ var styles = __vue_create_injector__.styles || (__vue_create_injector__.styles = {});
+ var isOldIE =
+ typeof navigator !== 'undefined' &&
+ /msie [6-9]\\b/.test(navigator.userAgent.toLowerCase());
+
+ return function addStyle(id, css) {
+ if (document.querySelector('style[data-vue-ssr-id~="' + id + '"]')) { return } // SSR styles are present.
+
+ var group = isOldIE ? css.media || 'default' : id;
+ var style = styles[group] || (styles[group] = { ids: [], parts: [], element: undefined });
+
+ if (!style.ids.includes(id)) {
+ var code = css.source;
+ var index = style.ids.length;
+
+ style.ids.push(id);
+
+ if (isOldIE) {
+ style.element = style.element || document.querySelector('style[data-group=' + group + ']');
+ }
+
+ if (!style.element) {
+ var el = style.element = document.createElement('style');
+ el.type = 'text/css';
+
+ if (css.media) { el.setAttribute('media', css.media); }
+ if (isOldIE) {
+ el.setAttribute('data-group', group);
+ el.setAttribute('data-next-index', '0');
+ }
+
+ head.appendChild(el);
+ }
+
+ if (isOldIE) {
+ index = parseInt(style.element.getAttribute('data-next-index'));
+ style.element.setAttribute('data-next-index', index + 1);
+ }
+
+ if (style.element.styleSheet) {
+ style.parts.push(code);
+ style.element.styleSheet.cssText = style.parts
+ .filter(Boolean)
+ .join('\n');
+ } else {
+ var textNode = document.createTextNode(code);
+ var nodes = style.element.childNodes;
+ if (nodes[index]) { style.element.removeChild(nodes[index]); }
+ if (nodes.length) { style.element.insertBefore(textNode, nodes[index]); }
+ else { style.element.appendChild(textNode); }
+ }
+ }
+ }
+ }
+ /* style inject SSR */
+
+
+
+ __vue_normalize__(
+ { render: __vue_render__, staticRenderFns: __vue_staticRenderFns__ },
+ __vue_inject_styles__,
+ __vue_script__,
+ __vue_scope_id__,
+ __vue_is_functional_template__,
+ __vue_module_identifier__,
+ __vue_create_injector__,
+ undefined
+ );
+
+ $(document).ready(function () {
+ $(".dropdown-notifications").after('');
+ $("#labels-toolbar").click(function(page) {
+ setupLabelsDialog(page);
+ });
+
+ });
+
+
+
+ function setupLabelsDialog(page) {
+ var cur_frm = page.view.cur_frm;
+
+ var fields = {
+ doctype: '',
+ docname: ' ',
+ item_code: '',
+ item_name: '',
+ delivery_date: '',
+ customer: '',
+ batch: '',
+ information: '',
+ total_amount: 0,
+ labels: [{
+ qty_per_label: 0,
+ is_warehouse: 0,
+ information: '',
+ }],
+ preview: __('Click "Render Preview"')
+ };
+
+
+ if (cur_frm !== null) {
+ if (cur_frm.doctype === "Work Order" || cur_frm.doctype === "Item") {
+ if (cur_frm.docname) {
+ fields.doctype = cur_frm.doctype;
+ fields.docname = cur_frm.docname;
+ }
+ }
+ }
+
+ var d = new frappe.ui.Dialog({
+ title: __("Print Labels"),
+ fields: [{
+ label: __("Reference Doctype"),
+ options: ['Work Order', 'Item'],
+ fieldname: 'doctype',
+ fieldtype: 'Select',
+ default: fields.doctype,
+ },
+ {
+ label: __("Get data"),
+ fieldname: 'get_data',
+ fieldtype: 'Button',
+ click: function () {
+ handleDataFetch();
+ }
+ },
+ {
+ fieldtype: 'Column Break'
+ },
+ {
+ label: __("Reference Docname"),
+ fieldname: 'docname',
+ fieldtype: 'Dynamic Link',
+ options: 'doctype',
+ },
+ {
+ fieldtype: 'Section Break',
+ label: __('Information')
+ },
+ {
+ label: __("Item Code"),
+ fieldname: 'item_code',
+ fieldtype: 'Data'
+ },
+ {
+ label: __("Item Name"),
+ fieldname: 'item_name',
+ fieldtype: 'Data'
+ },
+ {
+ label: __("Delivery Date"),
+ fieldname: 'delivery_date',
+ fieldtype: 'Date'
+ },
+ {
+ fieldtype: 'Column Break'
+ },
+ {
+ label: __("Customer"),
+ fieldname: 'customer',
+ fieldtype: 'Data'
+ },
+ {
+ label: __("Batch"),
+ fieldname: 'batch',
+ fieldtype: 'Data'
+ },
+ {
+ fieldtype: 'Section Break',
+ label: __('Labels')
+ },
+ {
+ fieldname: "labels",
+ fieldtype: "Table",
+ cannot_add_rows: false,
+ in_place_edit: true,
+ data: fields.labels,
+ get_data: function () {
+ return fields.labels;
+ },
+ fields: [{
+ fieldtype: 'Int',
+ fieldname: "item_qty",
+ in_list_view: 1,
+ label: __('Item Qty')
+ },
+ {
+ label: __("Label Qty"),
+ fieldname: 'label_qty',
+ in_list_view: 1,
+ fieldtype: 'Int'
+ } ]
+ } ],
+ primary_action_label: 'Print',
+ primary_action: function primary_action(values) {
+ fields = values;
+
+ frappe.call({
+ method: "label_printing.label_printing.api.create_labels",
+ args: {
+ values: fields
+ },
+ callback: function(r) {
+ if (r.message === 200) {
+ frappe.show_alert("Label printing successful", 5);
+ }
+ },
+ });
+
+ d.hide();
+ }
+ });
+ handleDataFetch();
+
+ d.show();
+
+
+ // handle dpctype change
+ d.fields_dict.doctype.$input.on('change', function() {
+ d.fields_dict.docname.refresh();
+ });
+
+ function handleDataFetch() {
+ fields = d.get_values();
+ if (fields.doctype && fields.docname) {
+ var doc = get_doc(fields.doctype, fields.docname);
+
+ if (fields.doctype === "Work Order") {
+ var item = get_doc("Item", doc.production_item);
+ fields.item_code = item.item_code;
+ fields.item_name = item.item_name;
+ fields.delivery_date = doc.expected_delivery_date;
+
+ if (item.associated_company) {
+ var customer = get_doc("Customer", item.associated_company);
+ if (customer.short_name) {
+ fields.customer = customer.short_name;
+ } else {
+ fields.customer = item.associated_company;
+ }
+ }
+
+ fields.total_amount = doc.qty;
+ fields.labels[0].qty_per_label = doc.qty;
+ d.fields_dict.labels.refresh();
+
+ } else if (fields.doctype === "Item") {
+ var item$1 = get_doc("Item", doc.item_code);
+
+ fields.item_code = doc.item_code;
+ fields.item_name = doc.item_name;
+
+ if (item$1.associated_company) {
+ var customer$1 = get_doc("Customer", doc.associated_company);
+ if (customer$1.short_name) {
+ fields.customer = customer$1.short_name;
+ } else {
+ fields.customer = doc.associated_company;
+ }
+ }
+ }
+
+ d.set_values(fields);
+ }
+ }
+
+ }
+
+ function get_doc(doctype, docname) {
+ var res;
+ frappe.call({
+ method: "frappe.client.get",
+ async: false,
+ args: {
+ doctype: doctype,
+ name: docname,
+ },
+ callback: function callback(r) {
+ if (r.message) {
+ res = r.message;
+ }
+ }
+ });
+ return res;
+ }
+
+}());
+//# sourceMappingURL=label_printing.min.js.map
diff --git a/label_printing/public/js/label_printing.min.js.map b/label_printing/public/js/label_printing.min.js.map
new file mode 100644
index 0000000..3657f43
--- /dev/null
+++ b/label_printing/public/js/label_printing.min.js.map
@@ -0,0 +1 @@
+{"version":3,"file":"label_printing.min.js","sources":["../../../../apps/label_printing/label_printing/public/js/label_printing_dialog.vue?rollup-plugin-vue=script.js","../../../../apps/label_printing/label_printing/public/js/label_printing_dialog.vue","../../../../apps/label_printing/label_printing/public/js/label_printing_desk.js"],"sourcesContent":["//\n//\n//\n//\n//\n//\n//\n//\n\nexport default {\n name: \"LabelPrintingDialog\",\n props: [],\n methods: {},\n};\n","\n \n \n \n \n \n\n\n\n\n","import LabelPrintingDialog from \"./label_printing_dialog.vue\";\n\n$(document).ready(function () {\n $(\".dropdown-notifications\").after('');\n $(\"#labels-toolbar\").click(function(page) {\n setupLabelsDialog(page);\n });\n\n});\n\n\n\nfunction setupLabelsDialog(page) {\n let cur_frm = page.view.cur_frm\n\n let fields = {\n doctype: '',\n docname: ' ',\n item_code: '',\n item_name: '',\n delivery_date: '',\n customer: '',\n batch: '',\n information: '',\n total_amount: 0,\n labels: [{\n qty_per_label: 0,\n is_warehouse: 0,\n information: '',\n }],\n preview: __('Click \"Render Preview\"')\n };\n\n\n if (cur_frm !== null) {\n if (cur_frm.doctype === \"Work Order\" || cur_frm.doctype === \"Item\") {\n if (cur_frm.docname) {\n fields.doctype = cur_frm.doctype\n fields.docname = cur_frm.docname\n }\n }\n }\n\n let d = new frappe.ui.Dialog({\n title: __(\"Print Labels\"),\n fields: [{\n label: __(\"Reference Doctype\"),\n options: ['Work Order', 'Item'],\n fieldname: 'doctype',\n fieldtype: 'Select',\n default: fields.doctype,\n },\n {\n label: __(\"Get data\"),\n fieldname: 'get_data',\n fieldtype: 'Button',\n click: () => {\n\t\t\t\t\t\t\thandleDataFetch()\n\t\t\t\t\t\t}\n },\n {\n fieldtype: 'Column Break'\n },\n {\n label: __(\"Reference Docname\"),\n fieldname: 'docname',\n fieldtype: 'Dynamic Link',\n options: 'doctype',\n },\n {\n fieldtype: 'Section Break',\n label: __('Information')\n },\n {\n label: __(\"Item Code\"),\n fieldname: 'item_code',\n fieldtype: 'Data'\n },\n {\n label: __(\"Item Name\"),\n fieldname: 'item_name',\n fieldtype: 'Data'\n },\n {\n label: __(\"Delivery Date\"),\n fieldname: 'delivery_date',\n fieldtype: 'Date'\n },\n {\n fieldtype: 'Column Break'\n },\n {\n label: __(\"Customer\"),\n fieldname: 'customer',\n fieldtype: 'Data'\n },\n {\n label: __(\"Batch\"),\n fieldname: 'batch',\n fieldtype: 'Data'\n },\n {\n fieldtype: 'Section Break',\n label: __('Labels')\n },\n {\n fieldname: \"labels\",\n fieldtype: \"Table\",\n cannot_add_rows: false,\n in_place_edit: true,\n data: fields.labels,\n get_data: () => {\n return fields.labels;\n },\n fields: [{\n fieldtype: 'Int',\n fieldname: \"item_qty\",\n in_list_view: 1,\n label: __('Item Qty')\n },\n {\n label: __(\"Label Qty\"),\n fieldname: 'label_qty',\n in_list_view: 1,\n fieldtype: 'Int'\n },\n ]\n },\n ],\n primary_action_label: 'Print',\n primary_action(values) {\n fields = values\n\n frappe.call({\n method: \"label_printing.label_printing.api.create_labels\",\n args: {\n values: fields\n },\n callback: function(r) {\n if (r.message === 200) {\n frappe.show_alert(\"Label printing successful\", 5);\n }\n },\n });\n\n d.hide();\n }\n });\n handleDataFetch();\n\n d.show();\n \n\n // handle dpctype change\n d.fields_dict.doctype.$input.on('change', function() {\n d.fields_dict.docname.refresh();\n });\n\n function handleDataFetch() {\n fields = d.get_values()\n if (fields.doctype && fields.docname) {\n let doc = get_doc(fields.doctype, fields.docname)\n\n if (fields.doctype === \"Work Order\") {\n let item = get_doc(\"Item\", doc.production_item)\n fields.item_code = item.item_code\n fields.item_name = item.item_name\n fields.delivery_date = doc.expected_delivery_date\n\n if (item.associated_company) {\n let customer = get_doc(\"Customer\", item.associated_company)\n if (customer.short_name) {\n fields.customer = customer.short_name\n } else {\n fields.customer = item.associated_company\n }\n }\n\n fields.total_amount = doc.qty\n fields.labels[0].qty_per_label = doc.qty\n d.fields_dict.labels.refresh();\n\n } else if (fields.doctype === \"Item\") {\n let item = get_doc(\"Item\", doc.item_code)\n\n fields.item_code = doc.item_code\n fields.item_name = doc.item_name\n\n if (item.associated_company) {\n let customer = get_doc(\"Customer\", doc.associated_company)\n if (customer.short_name) {\n fields.customer = customer.short_name\n } else {\n fields.customer = doc.associated_company\n }\n }\n }\n\n d.set_values(fields)\n }\n }\n\n}\n\nfunction get_doc(doctype, docname) {\n let res;\n frappe.call({\n method: \"frappe.client.get\",\n async: false,\n args: {\n doctype: doctype,\n name: docname,\n },\n callback(r) {\n if (r.message) {\n res = r.message\n }\n }\n });\n return res;\n}"],"names":["const","let","item","customer"],"mappings":";;;EAAA;;;;;;;;;AASA,eAAe;IACb,IAAI,EAAE,qBAAqB;IAC3B,KAAK,EAAE,EAAE;IACT,OAAO,EAAE,EAAE;GACZ,CAAC;;;cCVUA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ECDZ,CAAC,CAAC,QAAQ,CAAC,CAAC,KAAK,CAAC,YAAY;MAC1B,CAAC,CAAC,yBAAyB,CAAC,CAAC,KAAK,CAAC,yJAAyJ,CAAC,CAAC;MAC9L,CAAC,CAAC,iBAAiB,CAAC,CAAC,KAAK,CAAC,SAAS,IAAI,EAAE;MAC1C,iBAAiB,CAAC,IAAI,CAAC,CAAC;KACzB,CAAC,CAAC;;GAEJ,CAAC,CAAC;;;;EAIH,SAAS,iBAAiB,CAAC,IAAI,EAAE;IAC/BC,IAAI,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,QAAO;;IAE/BA,IAAI,MAAM,GAAG;MACX,OAAO,EAAE,EAAE;MACX,OAAO,EAAE,GAAG;MACZ,SAAS,EAAE,EAAE;MACb,SAAS,EAAE,EAAE;MAC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/public/js/label_printing_desk.js b/label_printing/public/js/label_printing_desk.js
new file mode 100644
index 0000000..fe072d6
--- /dev/null
+++ b/label_printing/public/js/label_printing_desk.js
@@ -0,0 +1,221 @@
+import LabelPrintingDialog from "./label_printing_dialog.vue";
+
+$(document).ready(function () {
+ $(".dropdown-notifications").after('');
+ $("#labels-toolbar").click(function(page) {
+ setupLabelsDialog(page);
+ });
+
+});
+
+
+
+function setupLabelsDialog(page) {
+ let cur_frm = page.view.cur_frm
+
+ let fields = {
+ doctype: '',
+ docname: ' ',
+ item_code: '',
+ item_name: '',
+ delivery_date: '',
+ customer: '',
+ batch: '',
+ information: '',
+ total_amount: 0,
+ labels: [{
+ qty_per_label: 0,
+ is_warehouse: 0,
+ information: '',
+ }],
+ preview: __('Click "Render Preview"')
+ };
+
+
+ if (cur_frm !== null) {
+ if (cur_frm.doctype === "Work Order" || cur_frm.doctype === "Item") {
+ if (cur_frm.docname) {
+ fields.doctype = cur_frm.doctype
+ fields.docname = cur_frm.docname
+ }
+ }
+ }
+
+ let d = new frappe.ui.Dialog({
+ title: __("Print Labels"),
+ fields: [{
+ label: __("Reference Doctype"),
+ options: ['Work Order', 'Item'],
+ fieldname: 'doctype',
+ fieldtype: 'Select',
+ default: fields.doctype,
+ },
+ {
+ label: __("Get data"),
+ fieldname: 'get_data',
+ fieldtype: 'Button',
+ click: () => {
+ handleDataFetch()
+ }
+ },
+ {
+ fieldtype: 'Column Break'
+ },
+ {
+ label: __("Reference Docname"),
+ fieldname: 'docname',
+ fieldtype: 'Dynamic Link',
+ options: 'doctype',
+ },
+ {
+ fieldtype: 'Section Break',
+ label: __('Information')
+ },
+ {
+ label: __("Item Code"),
+ fieldname: 'item_code',
+ fieldtype: 'Data'
+ },
+ {
+ label: __("Item Name"),
+ fieldname: 'item_name',
+ fieldtype: 'Data'
+ },
+ {
+ label: __("Delivery Date"),
+ fieldname: 'delivery_date',
+ fieldtype: 'Date'
+ },
+ {
+ fieldtype: 'Column Break'
+ },
+ {
+ label: __("Customer"),
+ fieldname: 'customer',
+ fieldtype: 'Data'
+ },
+ {
+ label: __("Batch"),
+ fieldname: 'batch',
+ fieldtype: 'Data'
+ },
+ {
+ fieldtype: 'Section Break',
+ label: __('Labels')
+ },
+ {
+ fieldname: "labels",
+ fieldtype: "Table",
+ cannot_add_rows: false,
+ in_place_edit: true,
+ data: fields.labels,
+ get_data: () => {
+ return fields.labels;
+ },
+ fields: [{
+ fieldtype: 'Int',
+ fieldname: "item_qty",
+ in_list_view: 1,
+ label: __('Item Qty')
+ },
+ {
+ label: __("Label Qty"),
+ fieldname: 'label_qty',
+ in_list_view: 1,
+ fieldtype: 'Int'
+ },
+ ]
+ },
+ ],
+ primary_action_label: 'Print',
+ primary_action(values) {
+ fields = values
+
+ frappe.call({
+ method: "label_printing.label_printing.api.create_labels",
+ args: {
+ values: fields
+ },
+ callback: function(r) {
+ if (r.message === 200) {
+ frappe.show_alert("Label printing successful", 5);
+ }
+ },
+ });
+
+ d.hide();
+ }
+ });
+ handleDataFetch();
+
+ d.show();
+
+
+ // handle dpctype change
+ d.fields_dict.doctype.$input.on('change', function() {
+ d.fields_dict.docname.refresh();
+ });
+
+ function handleDataFetch() {
+ fields = d.get_values()
+ if (fields.doctype && fields.docname) {
+ let doc = get_doc(fields.doctype, fields.docname)
+
+ if (fields.doctype === "Work Order") {
+ let item = get_doc("Item", doc.production_item)
+ fields.item_code = item.item_code
+ fields.item_name = item.item_name
+ fields.delivery_date = doc.expected_delivery_date
+
+ if (item.associated_company) {
+ let customer = get_doc("Customer", item.associated_company)
+ if (customer.short_name) {
+ fields.customer = customer.short_name
+ } else {
+ fields.customer = item.associated_company
+ }
+ }
+
+ fields.total_amount = doc.qty
+ fields.labels[0].qty_per_label = doc.qty
+ d.fields_dict.labels.refresh();
+
+ } else if (fields.doctype === "Item") {
+ let item = get_doc("Item", doc.item_code)
+
+ fields.item_code = doc.item_code
+ fields.item_name = doc.item_name
+
+ if (item.associated_company) {
+ let customer = get_doc("Customer", doc.associated_company)
+ if (customer.short_name) {
+ fields.customer = customer.short_name
+ } else {
+ fields.customer = doc.associated_company
+ }
+ }
+ }
+
+ d.set_values(fields)
+ }
+ }
+
+}
+
+function get_doc(doctype, docname) {
+ let res;
+ frappe.call({
+ method: "frappe.client.get",
+ async: false,
+ args: {
+ doctype: doctype,
+ name: docname,
+ },
+ callback(r) {
+ if (r.message) {
+ res = r.message
+ }
+ }
+ });
+ return res;
+}
\ No newline at end of file
diff --git a/label_printing/public/js/label_printing_dialog.vue b/label_printing/public/js/label_printing_dialog.vue
new file mode 100644
index 0000000..e95216a
--- /dev/null
+++ b/label_printing/public/js/label_printing_dialog.vue
@@ -0,0 +1,18 @@
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file