Rushabh Mehta | 06fa46f | 2015-01-29 18:09:11 +0530 | [diff] [blame] | 1 | frappe.pages['pos'].on_page_load = function(wrapper) { |
Rushabh Mehta | 4c36d73 | 2015-01-01 15:59:34 +0530 | [diff] [blame] | 2 | var page = frappe.ui.make_app_page({ |
Rushabh Mehta | 72e1719 | 2014-08-08 15:30:49 +0530 | [diff] [blame] | 3 | parent: wrapper, |
Rushabh Mehta | c4dce99 | 2015-03-05 15:09:04 +0530 | [diff] [blame] | 4 | title: __('Start Point-of-Sale (POS)'), |
Rushabh Mehta | 72e1719 | 2014-08-08 15:30:49 +0530 | [diff] [blame] | 5 | single_column: true |
| 6 | }); |
| 7 | |
Rushabh Mehta | c4dce99 | 2015-03-05 15:09:04 +0530 | [diff] [blame] | 8 | page.main.html(frappe.render_template("pos_page", {})); |
Rushabh Mehta | 72e1719 | 2014-08-08 15:30:49 +0530 | [diff] [blame] | 9 | |
| 10 | var pos_type = frappe.ui.form.make_control({ |
Rushabh Mehta | 4c36d73 | 2015-01-01 15:59:34 +0530 | [diff] [blame] | 11 | parent: page.main.find(".select-type"), |
Rushabh Mehta | 72e1719 | 2014-08-08 15:30:49 +0530 | [diff] [blame] | 12 | df: { |
| 13 | fieldtype: "Select", |
| 14 | options: [ |
| 15 | {label: __("Billing (Sales Invoice)"), value:"Sales Invoice"}, |
| 16 | {value:"Sales Order"}, |
| 17 | {value:"Delivery Note"}, |
| 18 | {value:"Quotation"}, |
| 19 | {value:"Purchase Order"}, |
| 20 | {value:"Purchase Receipt"}, |
| 21 | {value:"Purchase Invoice"}, |
| 22 | ], |
| 23 | fieldname: "pos_type" |
| 24 | }, |
| 25 | only_input: true |
| 26 | }); |
| 27 | |
| 28 | pos_type.refresh(); |
| 29 | |
Rushabh Mehta | c4dce99 | 2015-03-05 15:09:04 +0530 | [diff] [blame] | 30 | pos_type.set_input("Sales Invoice"); |
| 31 | |
Rushabh Mehta | 4c36d73 | 2015-01-01 15:59:34 +0530 | [diff] [blame] | 32 | page.main.find(".btn-primary").on("click", function() { |
Rushabh Mehta | 72e1719 | 2014-08-08 15:30:49 +0530 | [diff] [blame] | 33 | erpnext.open_as_pos = true; |
| 34 | new_doc(pos_type.get_value()); |
| 35 | }); |
| 36 | |
| 37 | $.ajax({ |
Rushabh Mehta | a27cca9 | 2015-05-20 15:43:17 +0530 | [diff] [blame] | 38 | url: "/api/resource/POS Profile", |
Rushabh Mehta | 72e1719 | 2014-08-08 15:30:49 +0530 | [diff] [blame] | 39 | success: function(data) { |
| 40 | if(!data.data.length) { |
Rushabh Mehta | 4c36d73 | 2015-01-01 15:59:34 +0530 | [diff] [blame] | 41 | page.main.find(".pos-setting-message").removeClass('hide'); |
Rushabh Mehta | 72e1719 | 2014-08-08 15:30:49 +0530 | [diff] [blame] | 42 | } |
| 43 | } |
| 44 | }) |
| 45 | |
| 46 | } |