Default Setup

This commit is contained in:
Christian Anetzberger
2022-01-19 15:29:58 +01:00
parent ec879853d0
commit 182cf5aeef
16 changed files with 812 additions and 20 deletions

View File

@@ -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"
@@ -178,4 +178,3 @@ user_data_fields = [
# auth_hooks = [
# "label_printing.auth.validate"
# ]

View File

@@ -0,0 +1,7 @@
import frappe
@frappe.whitelist()
def create_labels(values):
print(values)
return 200

View File

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

View File

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

View File

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

View File

@@ -0,0 +1,8 @@
# Copyright (c) 2022, CAnetzberger Design and Contributors
# See license.txt
# import frappe
import unittest
class TestLabels(unittest.TestCase):
pass

View File

@@ -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": "<div class=\"row\">\n <div class=\"col-10 text-center\">\n <h5>{{doc.item_code}}</h5>\n <h6>{{doc.item_name}}</h6>\n {% if doc.customer %}\n <p>{{doc.customer}}</p>\n {% endif %}\n {% if doc.delivery_date %}\n <p>{{_(\"Delivery Date\")}}: {{frappe.utils.formatdate(doc.delivery_date, \"dd.MM.YYYY\")}}</p>\n {% endif %}\n {% if doc.batch %}\n <p>{{_(\"Batch\")}}: {{doc.batch}}</p>\n {% endif %}\n </div>\n</div>",
"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"
}

View File

@@ -0,0 +1,5 @@
{
"label_printing/js/label_printing.min.js": [
"public/js/label_printing_desk.js"
]
}

View File

@@ -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('<li id="labels-toolbar" class="nav-item"><a class="nav-link label-printing-icon text-muted"><i class="fa fa-tag fa-lg" aria-hidden="true"></i></a></li>');
$("#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

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,221 @@
import LabelPrintingDialog from "./label_printing_dialog.vue";
$(document).ready(function () {
$(".dropdown-notifications").after('<li id="labels-toolbar" class="nav-item"><a class="nav-link label-printing-icon text-muted"><i class="fa fa-tag fa-lg" aria-hidden="true"></i></a></li>');
$("#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;
}

View File

@@ -0,0 +1,18 @@
<template>
<li class="nav-item">
<a class="nav-link label-printing-icon text-muted">
<i class="fa fa-tag fa-lg" aria-hidden="true"></i>
</a>
</li>
</template>
<script>
export default {
name: "LabelPrintingDialog",
props: [],
methods: {},
};
</script>
<style>
</style>