Rushabh Mehta | 72e1719 | 2014-08-08 15:30:49 +0530 | [diff] [blame] | 1 | frappe.pages['pos'].onload = function(wrapper) { |
| 2 | frappe.ui.make_app_page({ |
| 3 | parent: wrapper, |
| 4 | title: 'Start POS', |
| 5 | single_column: true |
| 6 | }); |
| 7 | |
| 8 | wrapper.body.html('<div class="text-center" style="margin: 40px">\ |
| 9 | <p>' + __("Select type of transaction") + '</p>\ |
| 10 | <p class="select-type" style="margin: auto; max-width: 300px; margin-bottom: 15px;"></p>\ |
| 11 | <p class="alert alert-warning pos-setting-message hide">' |
| 12 | + __("Please setup your POS Preferences") |
| 13 | + ': <a class="btn btn-default" onclick="newdoc(\'POS Setting\')">' |
| 14 | + __("Make new POS Setting") + '</a></p>\ |
| 15 | <p><button class="btn btn-primary">' + __("Start") + '</button></p>\ |
| 16 | </div>'); |
| 17 | |
| 18 | var pos_type = frappe.ui.form.make_control({ |
| 19 | parent: wrapper.body.find(".select-type"), |
| 20 | df: { |
| 21 | fieldtype: "Select", |
| 22 | options: [ |
| 23 | {label: __("Billing (Sales Invoice)"), value:"Sales Invoice"}, |
| 24 | {value:"Sales Order"}, |
| 25 | {value:"Delivery Note"}, |
| 26 | {value:"Quotation"}, |
| 27 | {value:"Purchase Order"}, |
| 28 | {value:"Purchase Receipt"}, |
| 29 | {value:"Purchase Invoice"}, |
| 30 | ], |
| 31 | fieldname: "pos_type" |
| 32 | }, |
| 33 | only_input: true |
| 34 | }); |
| 35 | |
| 36 | pos_type.refresh(); |
| 37 | |
| 38 | wrapper.body.find(".btn-primary").on("click", function() { |
| 39 | erpnext.open_as_pos = true; |
| 40 | new_doc(pos_type.get_value()); |
| 41 | }); |
| 42 | |
| 43 | $.ajax({ |
| 44 | url: "/api/resource/POS Setting", |
| 45 | success: function(data) { |
| 46 | if(!data.data.length) { |
| 47 | wrapper.body.find(".pos-setting-message").removeClass('hide'); |
| 48 | } |
| 49 | } |
| 50 | }) |
| 51 | |
| 52 | } |