From a9ba5eff992da3e4c9d9164dac3a26e06b09c89f Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Fri, 19 Dec 2014 16:20:32 +0530 Subject: [PATCH] [design] pos --- .../purchase_invoice/purchase_invoice.js | 1 - .../doctype/sales_invoice/sales_invoice.js | 1 - .../page/accounts_browser/accounts_browser.js | 2 +- .../financial_analytics.js | 2 +- .../doctype/purchase_order/purchase_order.js | 1 - .../supplier_quotation/supplier_quotation.js | 1 - .../purchase_analytics/purchase_analytics.js | 2 +- erpnext/controllers/status_updater.py | 6 +- erpnext/public/build.json | 5 +- erpnext/public/css/erpnext.css | 67 ++++++- erpnext/public/js/conf.js | 9 +- erpnext/public/js/pos/pos.html | 55 +++++ .../sales_invoice => public/js/pos}/pos.js | 189 ++++-------------- erpnext/public/js/pos/pos_bill_item.html | 16 ++ erpnext/public/js/transaction.js | 10 +- .../selling/doctype/quotation/quotation.js | 1 - .../doctype/sales_order/sales_order.js | 1 - .../page/sales_analytics/sales_analytics.js | 2 +- .../page/sales_browser/sales_browser.js | 2 +- .../selling/page/sales_funnel/sales_funnel.js | 80 ++++---- .../doctype/delivery_note/delivery_note.js | 1 - .../purchase_receipt/purchase_receipt.js | 1 - .../page/stock_analytics/stock_analytics.js | 2 +- .../stock/page/stock_ledger/stock_ledger.js | 2 +- erpnext/stock/page/stock_level/stock_level.js | 2 +- .../support_analytics/support_analytics.js | 2 +- 26 files changed, 228 insertions(+), 235 deletions(-) create mode 100644 erpnext/public/js/pos/pos.html rename erpnext/{accounts/doctype/sales_invoice => public/js/pos}/pos.js (70%) create mode 100644 erpnext/public/js/pos/pos_bill_item.html diff --git a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js index 69e5873de6..658cc52634 100644 --- a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js +++ b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js @@ -8,7 +8,6 @@ cur_frm.cscript.other_fname = "other_charges"; frappe.provide("erpnext.accounts"); {% include 'buying/doctype/purchase_common/purchase_common.js' %}; {% include 'accounts/doctype/purchase_taxes_and_charges_master/purchase_taxes_and_charges_master.js' %} -{% include 'accounts/doctype/sales_invoice/pos.js' %} erpnext.accounts.PurchaseInvoice = erpnext.buying.BuyingController.extend({ onload: function() { diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.js b/erpnext/accounts/doctype/sales_invoice/sales_invoice.js index f376126eef..2061fb198c 100644 --- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.js +++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.js @@ -11,7 +11,6 @@ cur_frm.pformat.print_heading = 'Invoice'; {% include 'selling/sales_common.js' %}; {% include 'accounts/doctype/sales_taxes_and_charges_master/sales_taxes_and_charges_master.js' %} -{% include 'accounts/doctype/sales_invoice/pos.js' %} frappe.provide("erpnext.accounts"); erpnext.accounts.SalesInvoiceController = erpnext.selling.SellingController.extend({ diff --git a/erpnext/accounts/page/accounts_browser/accounts_browser.js b/erpnext/accounts/page/accounts_browser/accounts_browser.js index c927596d51..dc0dd7a95e 100644 --- a/erpnext/accounts/page/accounts_browser/accounts_browser.js +++ b/erpnext/accounts/page/accounts_browser/accounts_browser.js @@ -13,7 +13,7 @@ pscript['onload_Accounts Browser'] = function(wrapper){ single_column: true }) - wrapper.appframe.add_module_icon("Accounts"); + frappe.add_breadcrumbs("Accounts"); var main = $(wrapper).find(".layout-main"), chart_area = $("
") diff --git a/erpnext/accounts/page/financial_analytics/financial_analytics.js b/erpnext/accounts/page/financial_analytics/financial_analytics.js index 2da93813e9..f0fdffecd2 100644 --- a/erpnext/accounts/page/financial_analytics/financial_analytics.js +++ b/erpnext/accounts/page/financial_analytics/financial_analytics.js @@ -10,7 +10,7 @@ frappe.pages['financial-analytics'].onload = function(wrapper) { single_column: true }); erpnext.trial_balance = new erpnext.FinancialAnalytics(wrapper, 'Financial Analytics'); - wrapper.appframe.add_module_icon("Accounts") + frappe.add_breadcrumbs("Accounts") } diff --git a/erpnext/buying/doctype/purchase_order/purchase_order.js b/erpnext/buying/doctype/purchase_order/purchase_order.js index e712995c55..ed7e2c2ac4 100644 --- a/erpnext/buying/doctype/purchase_order/purchase_order.js +++ b/erpnext/buying/doctype/purchase_order/purchase_order.js @@ -9,7 +9,6 @@ cur_frm.cscript.other_fname = "other_charges"; {% include 'buying/doctype/purchase_common/purchase_common.js' %}; {% include 'accounts/doctype/purchase_taxes_and_charges_master/purchase_taxes_and_charges_master.js' %} -{% include 'accounts/doctype/sales_invoice/pos.js' %} erpnext.buying.PurchaseOrderController = erpnext.buying.BuyingController.extend({ refresh: function(doc, cdt, cdn) { diff --git a/erpnext/buying/doctype/supplier_quotation/supplier_quotation.js b/erpnext/buying/doctype/supplier_quotation/supplier_quotation.js index b9286a1c24..dda0632aa8 100644 --- a/erpnext/buying/doctype/supplier_quotation/supplier_quotation.js +++ b/erpnext/buying/doctype/supplier_quotation/supplier_quotation.js @@ -9,7 +9,6 @@ cur_frm.cscript.other_fname = "other_charges"; // attach required files {% include 'buying/doctype/purchase_common/purchase_common.js' %}; {% include 'accounts/doctype/purchase_taxes_and_charges_master/purchase_taxes_and_charges_master.js' %} -{% include 'accounts/doctype/sales_invoice/pos.js' %} erpnext.buying.SupplierQuotationController = erpnext.buying.BuyingController.extend({ refresh: function() { diff --git a/erpnext/buying/page/purchase_analytics/purchase_analytics.js b/erpnext/buying/page/purchase_analytics/purchase_analytics.js index f1c050d1ff..e1d6294d6f 100644 --- a/erpnext/buying/page/purchase_analytics/purchase_analytics.js +++ b/erpnext/buying/page/purchase_analytics/purchase_analytics.js @@ -11,7 +11,7 @@ frappe.pages['purchase-analytics'].onload = function(wrapper) { new erpnext.PurchaseAnalytics(wrapper); - wrapper.appframe.add_module_icon("Buying") + frappe.add_breadcrumbs("Buying") } diff --git a/erpnext/controllers/status_updater.py b/erpnext/controllers/status_updater.py index 247d4ffbda..0ec8bf0941 100644 --- a/erpnext/controllers/status_updater.py +++ b/erpnext/controllers/status_updater.py @@ -73,9 +73,7 @@ class StatusUpdater(Document): frappe.db.set_value(self.doctype, self.name, "status", self.status) def validate_qty(self): - """ - Validates qty at row level - """ + """Validates qty at row level""" self.tolerance = {} self.global_tolerance = None @@ -153,7 +151,7 @@ class StatusUpdater(Document): args['second_source_condition'] = "" if args.get('second_source_dt') and args.get('second_source_field') \ and args.get('second_join_field'): - if not args.get("second_source_extra_cond"): + if not args.get("second_source_extra_cond"): args["second_source_extra_cond"] = "" args['second_source_condition'] = """ + ifnull((select sum(%(second_source_field)s) diff --git a/erpnext/public/build.json b/erpnext/public/build.json index 49b09071fb..588f4ec86b 100644 --- a/erpnext/public/build.json +++ b/erpnext/public/build.json @@ -13,7 +13,10 @@ "public/js/queries.js", "public/js/utils/party.js", "public/js/templates/address_list.html", - "public/js/templates/contact_list.html" + "public/js/templates/contact_list.html", + "public/js/pos/pos.html", + "public/js/pos/pos_bill_item.html", + "public/js/pos/pos.js" ], "css/shopping-cart-web.css": [ "public/css/shopping_cart.css" diff --git a/erpnext/public/css/erpnext.css b/erpnext/public/css/erpnext.css index 6d3f4750fe..7a93757944 100644 --- a/erpnext/public/css/erpnext.css +++ b/erpnext/public/css/erpnext.css @@ -20,6 +20,9 @@ } /* pos */ +.pos { +} + .pos-item { height: 200px; overflow: hidden; @@ -28,10 +31,62 @@ padding-right: 5px !important; } -.pos-bill { - margin-left: -30px; - margin-top: -10px; - padding: 20px 10px; - border-right: 1px solid #c7c7c7; - border-bottom: 1px solid #c7c7c7; +.pos-item-area { + border: 1px solid #d1d8dd; + border-top: none; +} + +.pos-item-toolbar { + padding: 10px 0px; + border-bottom: 1px solid #d1d8dd; +} + +.item-list-area { + padding: 15px; +} + +.pos-toolbar, .pos-bill-toolbar { + padding: 10px 0px; + border-bottom: 1px solid #d1d8dd; + height: 55px; +} + +.pos-item-toolbar .form-group { + margin-bottom: 0px; +} + +.pos-bill-wrapper { + border: 1px solid #d1d8dd; + border-top: none; + border-right: none; +} + +.pos-bill { + margin-left: -15px; + margin-right: -15px; +} + +.pos-bill-row { + margin: 0px; + padding: 7px 0px; + border-top: 1px solid #d1d8dd; +} + +.pos-bill-header { + border: none !important; + background-color: #f5f7fa; +} + +.pos-item-qty { + display: inline-block; +} + +.pos-qty-row > div { + padding: 5px 0px; +} + +.pos-qty-btn { + margin-top: 5px; + cursor: pointer; + font-size: 120%; } diff --git a/erpnext/public/js/conf.js b/erpnext/public/js/conf.js index e9c790db10..deb6a2c609 100644 --- a/erpnext/public/js/conf.js +++ b/erpnext/public/js/conf.js @@ -7,14 +7,7 @@ frappe.provide('erpnext'); $(document).bind('toolbar_setup', function() { frappe.app.name = "ERPNext"; - $('.navbar-brand').html('') - .attr("title", "Home") - .addClass("navbar-icon-home") - .css({ - "max-width": "200px", - "text-overflow": "ellipsis", - "white-space": "nowrap" - }); + $('.navbar-brand').html('ERPNext'); $('[data-link="docs"]').attr("href", "https://erpnext.com/user-guide") }); diff --git a/erpnext/public/js/pos/pos.html b/erpnext/public/js/pos/pos.html new file mode 100644 index 0000000000..dd323bcc41 --- /dev/null +++ b/erpnext/public/js/pos/pos.html @@ -0,0 +1,55 @@ +
+
+
+
+
+
+ +
+
+
+
+
+
{%= __("Item") %}
+
{%= __("Quantity") %}
+
{%= __("Rate") %}
+
+
+
+
+
+
{%= __("Net Total") %}
+
+
+
+
{%= __("Taxes") %}
+
+
+
{%= __("Discount Amount") %}
+
+
+
+
{%= __("Grand Total") %}
+
+
+ +
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/erpnext/accounts/doctype/sales_invoice/pos.js b/erpnext/public/js/pos/pos.js similarity index 70% rename from erpnext/accounts/doctype/sales_invoice/pos.js rename to erpnext/public/js/pos/pos.js index 8c6e3cdb82..cfae51571d 100644 --- a/erpnext/accounts/doctype/sales_invoice/pos.js +++ b/erpnext/public/js/pos/pos.js @@ -5,105 +5,7 @@ erpnext.POS = Class.extend({ init: function(wrapper, frm) { this.wrapper = wrapper; this.frm = frm; - this.wrapper.html('
\ -
\ -
\ -
\ -
\ -
\ -
\ -
\ -
\ -
\ -
\ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ -
'+__("Item")+'QtyRate
\ -
\ -
\ -
\ -
\ - \ - \ - \ - \ - \ -
'+__("Net Total")+'
\ -
\ - \ -
\ - \ - \ - \ - \ - \ - \ -
'+__("Discount Amount")+'\ - \ -
\ -
\ -
\ - \ - \ - \ - \ - \ -
'+__("Grand Total")+'
\ -
\ - \ -
\ -
\ -

\ -
\ -
\ - \ -
\ -
\ - \ -
\ -
\ -

\ -
\ -
\ -
\ -
\ -
\ -
\ -
\ -
'); + this.wrapper.html(frappe.render_template("pos", {})); this.check_transaction_type(); this.make(); @@ -271,14 +173,8 @@ erpnext.POS = Class.extend({ // if form is local then allow this function $(me.wrapper).find("div.pos-item").on("click", function() { if(me.frm.doc.docstatus==0) { - if(!me.frm.doc[me.party.toLowerCase()] && ((me.frm.doctype == "Quotation" && - me.frm.doc.quotation_to == "Customer") - || me.frm.doctype != "Quotation")) { - msgprint(__("Please select {0} first.", [me.party])); - return; - } - else - me.add_to_cart($(this).attr("data-item_code")); + console.log($(this).attr("data-item_code")); + me.add_to_cart($(this).attr("data-item_code")); } }); } @@ -288,8 +184,15 @@ erpnext.POS = Class.extend({ var me = this; var caught = false; + if(!me.frm.doc[me.party.toLowerCase()] && ((me.frm.doctype == "Quotation" && + me.frm.doc.quotation_to == "Customer") + || me.frm.doctype != "Quotation")) { + msgprint(__("Please select {0} first.", [me.party])); + return; + } + // get no_of_items - var no_of_items = me.wrapper.find("#cart tbody tr").length; + var no_of_items = me.wrapper.find(".pos-bill-item").length; // check whether the item is already added if (no_of_items != 0) { @@ -333,6 +236,7 @@ erpnext.POS = Class.extend({ } }, update_qty: function(item_code, qty) { + console.log([item_code, qty]); var me = this; $.each(this.frm.doc[this.frm.cscript.fname] || [], function(i, d) { if (d.item_code == item_code) { @@ -368,7 +272,7 @@ erpnext.POS = Class.extend({ // If quotation to is not Customer then remove party if (this.frm.doctype == "Quotation" && this.frm.doc.quotation_to!="Customer") { - this.party_field.$wrapper.remove(); + this.party_field.$input.prop("disabled", true); } }, refresh_item_list: function() { @@ -381,45 +285,20 @@ erpnext.POS = Class.extend({ }, show_items_in_item_cart: function() { var me = this; - var $items = this.wrapper.find("#cart tbody").empty(); + var $items = this.wrapper.find(".items").empty(); $.each(this.frm.doc[this.frm.cscript.fname] || [], function(i, d) { - - $(repl('\ - %(item_code)s%(item_name)s\ - \ -
\ - \ -
\ - \ - \ - \ -
' - +__("Stock: ")+'%(actual_qty)s%(projected_qty)s
\ - \ - \ -
\ - \ -
\ - \ - %(amount)s
%(rate)s\ - ', - { - item_code: d.item_code, - item_name: d.item_name===d.item_code ? "" : ("
" + d.item_name), - qty: d.qty, - actual_qty: d.actual_qty, - projected_qty: d.projected_qty ? (" (" + d.projected_qty + ")") : "", - rate: format_currency(d.rate, me.frm.doc.currency), - amount: format_currency(d.amount, me.frm.doc.currency) - } - )).appendTo($items); + $(frappe.render_template("pos_bill_item", { + item_code: d.item_code, + item_name: d.item_name===d.item_code ? "" : ("
" + d.item_name), + qty: d.qty, + actual_qty: d.actual_qty, + rate: format_currency(d.rate, me.frm.doc.currency), + amount: format_currency(d.amount, me.frm.doc.currency) + })).appendTo($items); }); - this.wrapper.find("input.qty").on("focus", function() { + this.wrapper.find("input.pos-item-qty").on("focus", function() { $(this).select(); }); }, @@ -461,15 +340,15 @@ erpnext.POS = Class.extend({ var me = this; // append quantity to the respective item after change from input box - $(this.wrapper).find("input.qty").on("change", function() { + $(this.wrapper).find("input.pos-item-qty").on("change", function() { var item_code = $(this).closest("tr").attr("id"); me.update_qty(item_code, $(this).val()); }); // increase/decrease qty on plus/minus button - $(this.wrapper).find(".increase-qty, .decrease-qty").on("click", function() { - var tr = $(this).closest("tr"); - me.increase_decrease_qty(tr, $(this).attr("class")); + $(this.wrapper).find(".pos-qty-btn").on("click", function() { + var $item = $(this).parents(".pos-bill-item:first"); + me.increase_decrease_qty($item, $(this).attr("data-action")); }); // on td click toggle the highlighting of row @@ -487,15 +366,19 @@ erpnext.POS = Class.extend({ }); me.refresh_delete_btn(); + //me.focus(); + }, + focus: function() { if(me.frm.doc[this.party]) { this.barcode.$input.focus(); } else { - this.party_field.$input.focus(); + if(!(this.frm.doctype == "Quotation" && this.frm.doc.quotation_to!="Customer")) + this.party_field.$input.focus(); } }, - increase_decrease_qty: function(tr, operation) { - var item_code = tr.attr("id"); - var item_qty = cint(tr.find("input.qty").val()); + increase_decrease_qty: function($item, operation) { + var item_code = $item.attr("data-item-code"); + var item_qty = cint($item.find("input.pos-item-qty").val()); if (operation == "increase-qty") this.update_qty(item_code, item_qty + 1); @@ -506,7 +389,7 @@ erpnext.POS = Class.extend({ var me = this; // if form is submitted & cancelled then disable all input box & buttons $(this.wrapper) - .find(".remove-items, .make-payment, .increase-qty, .decrease-qty") + .find(".remove-items, .make-payment, .pos-qty-btn") .toggle(this.frm.doc.docstatus===0); $(this.wrapper).find('input, button').prop("disabled", !(this.frm.doc.docstatus===0)); diff --git a/erpnext/public/js/pos/pos_bill_item.html b/erpnext/public/js/pos/pos_bill_item.html new file mode 100644 index 0000000000..e45536f9c4 --- /dev/null +++ b/erpnext/public/js/pos/pos_bill_item.html @@ -0,0 +1,16 @@ +
+
{%= item_code %}{%= item_name %}
+
+
+
+
+ +
{%= actual_qty %}
+
+
+
+
+
+
{%= amount %}
{%= rate %}
+
+
diff --git a/erpnext/public/js/transaction.js b/erpnext/public/js/transaction.js index a261649813..5bbfae4641 100644 --- a/erpnext/public/js/transaction.js +++ b/erpnext/public/js/transaction.js @@ -105,12 +105,12 @@ erpnext.TransactionController = erpnext.stock.StockController.extend({ // make pos if(!this.frm.pos) { - this.frm.layout.add_view("pos"); - this.frm.pos = new erpnext.POS(this.frm.layout.views.pos, this.frm); + var wrapper = this.frm.appframe.add_view("pos", "
"); + this.frm.pos = new erpnext.POS(wrapper, this.frm); } // toggle view - this.frm.layout.set_view(this.pos_active ? "" : "pos"); + this.frm.appframe.set_view(this.pos_active ? "main" : "pos"); this.pos_active = !this.pos_active; // refresh @@ -224,9 +224,9 @@ erpnext.TransactionController = erpnext.stock.StockController.extend({ me.frm.script_manager.trigger("currency"); me.apply_pricing_rule(); - } + } } - + if (this.frm.doc.posting_date) var date = this.frm.doc.posting_date; else var date = this.frm.doc.transaction_date; erpnext.get_fiscal_year(this.frm.doc.company, date, fn); diff --git a/erpnext/selling/doctype/quotation/quotation.js b/erpnext/selling/doctype/quotation/quotation.js index 0026582967..cad9a8c146 100644 --- a/erpnext/selling/doctype/quotation/quotation.js +++ b/erpnext/selling/doctype/quotation/quotation.js @@ -10,7 +10,6 @@ cur_frm.cscript.sales_team_fname = "sales_team"; {% include 'selling/sales_common.js' %} {% include 'accounts/doctype/sales_taxes_and_charges_master/sales_taxes_and_charges_master.js' %} -{% include 'accounts/doctype/sales_invoice/pos.js' %} erpnext.selling.QuotationController = erpnext.selling.SellingController.extend({ onload: function(doc, dt, dn) { diff --git a/erpnext/selling/doctype/sales_order/sales_order.js b/erpnext/selling/doctype/sales_order/sales_order.js index 65b91f4bd7..2c196862f1 100644 --- a/erpnext/selling/doctype/sales_order/sales_order.js +++ b/erpnext/selling/doctype/sales_order/sales_order.js @@ -10,7 +10,6 @@ cur_frm.cscript.sales_team_fname = "sales_team"; {% include 'selling/sales_common.js' %} {% include 'accounts/doctype/sales_taxes_and_charges_master/sales_taxes_and_charges_master.js' %} -{% include 'accounts/doctype/sales_invoice/pos.js' %} erpnext.selling.SalesOrderController = erpnext.selling.SellingController.extend({ refresh: function(doc, dt, dn) { diff --git a/erpnext/selling/page/sales_analytics/sales_analytics.js b/erpnext/selling/page/sales_analytics/sales_analytics.js index 34808662ce..75863533ec 100644 --- a/erpnext/selling/page/sales_analytics/sales_analytics.js +++ b/erpnext/selling/page/sales_analytics/sales_analytics.js @@ -10,7 +10,7 @@ frappe.pages['sales-analytics'].onload = function(wrapper) { new erpnext.SalesAnalytics(wrapper); - wrapper.appframe.add_module_icon("Selling") + frappe.add_breadcrumbs("Selling") } diff --git a/erpnext/selling/page/sales_browser/sales_browser.js b/erpnext/selling/page/sales_browser/sales_browser.js index d254028865..fcbd71ca9d 100644 --- a/erpnext/selling/page/sales_browser/sales_browser.js +++ b/erpnext/selling/page/sales_browser/sales_browser.js @@ -6,7 +6,7 @@ pscript['onload_Sales Browser'] = function(wrapper){ parent: wrapper, }) - wrapper.appframe.add_module_icon("Selling") + frappe.add_breadcrumbs("Selling") wrapper.appframe.set_title_right(__('Refresh'), function() { wrapper.make_tree(); diff --git a/erpnext/selling/page/sales_funnel/sales_funnel.js b/erpnext/selling/page/sales_funnel/sales_funnel.js index 76707629cf..99d3d070b1 100644 --- a/erpnext/selling/page/sales_funnel/sales_funnel.js +++ b/erpnext/selling/page/sales_funnel/sales_funnel.js @@ -1,73 +1,71 @@ // Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors // License: GNU General Public License v3. See license.txt -frappe.pages['sales-funnel'].onload = function(wrapper) { +frappe.pages['sales-funnel'].onload = function(wrapper) { frappe.ui.make_app_page({ parent: wrapper, title: __('Sales Funnel'), single_column: true }); - + wrapper.sales_funnel = new erpnext.SalesFunnel(wrapper); - - wrapper.appframe.add_module_icon("Selling", "sales-funnel", function() { - frappe.set_route("selling-home"); - }); + + frappe.add_breadcrumbs("Selling"); } erpnext.SalesFunnel = Class.extend({ init: function(wrapper) { var me = this; // 0 setTimeout hack - this gives time for canvas to get width and height - setTimeout(function() { + setTimeout(function() { me.setup(wrapper); me.get_data(); }, 0); }, - + setup: function(wrapper) { var me = this; - - this.elements = { + + this.elements = { layout: $(wrapper).find(".layout-main"), from_date: wrapper.appframe.add_date(__("From Date")), to_date: wrapper.appframe.add_date(__("To Date")), - refresh_btn: wrapper.appframe.set_title_right(__("Refresh"), + refresh_btn: wrapper.appframe.set_title_right(__("Refresh"), function() { me.get_data(); }, "icon-refresh"), }; - + this.elements.no_data = $('
' + __("No Data") + '
') .toggle(false) .appendTo(this.elements.layout); - + this.elements.funnel_wrapper = $('
') .appendTo(this.elements.layout); - + this.options = { from_date: frappe.datetime.add_months(frappe.datetime.get_today(), -1), to_date: frappe.datetime.get_today() }; - + // set defaults and bind on change - $.each(this.options, function(k, v) { - me.elements[k].val(frappe.datetime.str_to_user(v)); + $.each(this.options, function(k, v) { + me.elements[k].val(frappe.datetime.str_to_user(v)); me.elements[k].on("change", function() { me.options[k] = frappe.datetime.user_to_str($(this).val()); me.get_data(); }); }); - + // bind refresh this.elements.refresh_btn.on("click", function() { me.get_data(this); }); - + // bind resize $(window).resize(function() { me.render(); }); }, - + get_data: function(btn) { var me = this; frappe.call({ @@ -85,72 +83,72 @@ erpnext.SalesFunnel = Class.extend({ } }); }, - + render: function() { var me = this; this.prepare(); - + var context = this.elements.context, x_start = 0.0, x_end = this.options.width, x_mid = (x_end - x_start) / 2.0, y = 0, y_old = 0.0; - + if(this.options.total_value === 0) { this.elements.no_data.toggle(true); return; } - + this.options.data.forEach(function(d) { context.fillStyle = d.color; context.strokeStyle = d.color; me.draw_triangle(x_start, x_mid, x_end, y, me.options.height); - + y_old = y; // new y y = y + d.height; - + // new x var half_side = (me.options.height - y) / Math.sqrt(3); x_start = x_mid - half_side; x_end = x_mid + half_side; - + var y_mid = y_old + (y - y_old) / 2.0; - + me.draw_legend(x_mid, y_mid, me.options.width, me.options.height, d.value + " - " + d.title); }); }, - + prepare: function() { var me = this; - + this.elements.no_data.toggle(false); - + // calculate width and height options this.options.width = $(this.elements.funnel_wrapper).width() * 2.0 / 3.0; this.options.height = (Math.sqrt(3) * this.options.width) / 2.0; - + // calculate total weightage // as height decreases, area decreases by the square of the reduction // hence, compensating by squaring the index value this.options.total_weightage = this.options.data.reduce( function(prev, curr, i) { return prev + Math.pow(i+1, 2) * curr.value; }, 0.0); - + // calculate height for each data $.each(this.options.data, function(i, d) { d.height = me.options.height * d.value * Math.pow(i+1, 2) / me.options.total_weightage; }); - + this.elements.canvas = $('') .appendTo(this.elements.funnel_wrapper.empty()) .attr("width", $(this.elements.funnel_wrapper).width()) .attr("height", this.options.height); - + this.elements.context = this.elements.canvas.get(0).getContext("2d"); }, - + draw_triangle: function(x_start, x_mid, x_end, y, height) { var context = this.elements.context; context.beginPath(); @@ -161,27 +159,27 @@ erpnext.SalesFunnel = Class.extend({ context.closePath(); context.fill(); }, - + draw_legend: function(x_mid, y_mid, width, height, title) { var context = this.elements.context; - + // draw line context.beginPath(); context.moveTo(x_mid, y_mid); context.lineTo(width, y_mid); context.closePath(); context.stroke(); - + // draw circle context.beginPath(); context.arc(width, y_mid, 5, 0, Math.PI * 2, false); context.closePath(); context.fill(); - + // draw text context.fillStyle = "black"; context.textBaseline = "middle"; context.font = "1.1em sans-serif"; context.fillText(title, width + 20, y_mid); } -}); \ No newline at end of file +}); diff --git a/erpnext/stock/doctype/delivery_note/delivery_note.js b/erpnext/stock/doctype/delivery_note/delivery_note.js index 6abc268f4a..354667a02a 100644 --- a/erpnext/stock/doctype/delivery_note/delivery_note.js +++ b/erpnext/stock/doctype/delivery_note/delivery_note.js @@ -9,7 +9,6 @@ cur_frm.cscript.sales_team_fname = "sales_team"; {% include 'selling/sales_common.js' %}; {% include 'accounts/doctype/sales_taxes_and_charges_master/sales_taxes_and_charges_master.js' %} -{% include 'accounts/doctype/sales_invoice/pos.js' %} frappe.provide("erpnext.stock"); frappe.provide("erpnext.stock.delivery_note"); diff --git a/erpnext/stock/doctype/purchase_receipt/purchase_receipt.js b/erpnext/stock/doctype/purchase_receipt/purchase_receipt.js index fc2d1b30f3..de2d0defce 100644 --- a/erpnext/stock/doctype/purchase_receipt/purchase_receipt.js +++ b/erpnext/stock/doctype/purchase_receipt/purchase_receipt.js @@ -7,7 +7,6 @@ cur_frm.cscript.other_fname = "other_charges"; {% include 'buying/doctype/purchase_common/purchase_common.js' %}; {% include 'accounts/doctype/purchase_taxes_and_charges_master/purchase_taxes_and_charges_master.js' %} -{% include 'accounts/doctype/sales_invoice/pos.js' %} frappe.provide("erpnext.stock"); erpnext.stock.PurchaseReceiptController = erpnext.buying.BuyingController.extend({ diff --git a/erpnext/stock/page/stock_analytics/stock_analytics.js b/erpnext/stock/page/stock_analytics/stock_analytics.js index 963cff0b75..8fd2d324f6 100644 --- a/erpnext/stock/page/stock_analytics/stock_analytics.js +++ b/erpnext/stock/page/stock_analytics/stock_analytics.js @@ -12,7 +12,7 @@ frappe.pages['stock-analytics'].onload = function(wrapper) { new erpnext.StockAnalytics(wrapper); - wrapper.appframe.add_module_icon("Stock") + frappe.add_breadcrumbs("Stock") } diff --git a/erpnext/stock/page/stock_ledger/stock_ledger.js b/erpnext/stock/page/stock_ledger/stock_ledger.js index b4086dc66e..84e5b9b61f 100644 --- a/erpnext/stock/page/stock_ledger/stock_ledger.js +++ b/erpnext/stock/page/stock_ledger/stock_ledger.js @@ -9,7 +9,7 @@ frappe.pages['stock-ledger'].onload = function(wrapper) { }); new erpnext.StockLedger(wrapper); - wrapper.appframe.add_module_icon("Stock") + frappe.add_breadcrumbs("Stock") } frappe.require("assets/erpnext/js/stock_grid_report.js"); diff --git a/erpnext/stock/page/stock_level/stock_level.js b/erpnext/stock/page/stock_level/stock_level.js index 8659c28729..785ad7fdfd 100644 --- a/erpnext/stock/page/stock_level/stock_level.js +++ b/erpnext/stock/page/stock_level/stock_level.js @@ -11,7 +11,7 @@ frappe.pages['stock-level'].onload = function(wrapper) { new erpnext.StockLevel(wrapper); - wrapper.appframe.add_module_icon("Stock") + frappe.add_breadcrumbs("Stock") ; } diff --git a/erpnext/support/page/support_analytics/support_analytics.js b/erpnext/support/page/support_analytics/support_analytics.js index 9e24f679e1..95c5fc8a72 100644 --- a/erpnext/support/page/support_analytics/support_analytics.js +++ b/erpnext/support/page/support_analytics/support_analytics.js @@ -11,7 +11,7 @@ frappe.pages['support-analytics'].onload = function(wrapper) { new erpnext.SupportAnalytics(wrapper); - wrapper.appframe.add_module_icon("Support") + frappe.add_breadcrumbs("Support") }