From d700279cc0112ef8805b1a0069a9336b08dc1497 Mon Sep 17 00:00:00 2001 From: Shivam Mishra Date: Fri, 2 Aug 2019 14:39:08 +0530 Subject: [PATCH] feat: updated ticket pricing forms --- .../conference_participant.json | 552 +++--------------- .../doctype/tshirt_sizes/__init__.py | 0 .../doctype/tshirt_sizes/tshirt_sizes.json | 38 ++ .../doctype/tshirt_sizes/tshirt_sizes.py | 10 + .../buy_tickets_inr/buy_tickets_inr.js | 32 +- .../buy_tickets_inr/buy_tickets_inr.json | 192 +++--- .../buy_tickets_paypal/buy_tickets_paypal.js | 30 +- .../buy_tickets_paypal.json | 195 ++++--- 8 files changed, 398 insertions(+), 651 deletions(-) create mode 100644 foundation/erpnext_foundation/doctype/tshirt_sizes/__init__.py create mode 100644 foundation/erpnext_foundation/doctype/tshirt_sizes/tshirt_sizes.json create mode 100644 foundation/erpnext_foundation/doctype/tshirt_sizes/tshirt_sizes.py diff --git a/foundation/erpnext_foundation/doctype/conference_participant/conference_participant.json b/foundation/erpnext_foundation/doctype/conference_participant/conference_participant.json index 54f1ffa5..33a74cdf 100644 --- a/foundation/erpnext_foundation/doctype/conference_participant/conference_participant.json +++ b/foundation/erpnext_foundation/doctype/conference_participant/conference_participant.json @@ -1,515 +1,135 @@ { - "allow_copy": 0, - "allow_guest_to_view": 0, - "allow_import": 0, - "allow_rename": 0, "autoname": "E-CON-.YYYY.-.###", - "beta": 0, - "creation": "2017-07-06 16:20:28.662095", - "custom": 0, - "docstatus": 0, - "doctype": "DocType", - "document_type": "", - "editable_grid": 1, - "engine": "InnoDB", + "creation": "2017-07-06 16:20:28.662095", + "doctype": "DocType", + "editable_grid": 1, + "engine": "InnoDB", + "field_order": [ + "participant_details_section", + "participant_name", + "column_break_3", + "email", + "conference_details_section", + "conference", + "full_conference_tickets", + "user_conference_tickets", + "paid", + "column_break_10", + "tshirt_table", + "tshirt_size", + "currency", + "amount", + "thank_you_email_sent" + ], "fields": [ { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, "fieldname": "participant_details_section", "fieldtype": "Section Break", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 0, - "in_standard_filter": 0, - "label": "Participant Details", - "length": 0, - "no_copy": 0, - "permlevel": 0, - "precision": "", - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 0, - "set_only_once": 0, - "translatable": 0, - "unique": 0 + "label": "Participant Details" }, { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, - "fieldname": "participant_name", - "fieldtype": "Data", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 1, - "in_standard_filter": 0, - "label": "Participant Name", - "length": 0, - "no_copy": 0, - "permlevel": 0, - "precision": "", - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 1, - "search_index": 0, - "set_only_once": 0, - "translatable": 0, - "unique": 0 - }, + "fieldname": "participant_name", + "fieldtype": "Data", + "in_list_view": 1, + "label": "Participant Name", + "reqd": 1 + }, { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, "fieldname": "column_break_3", - "fieldtype": "Column Break", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 0, - "in_standard_filter": 0, - "length": 0, - "no_copy": 0, - "permlevel": 0, - "precision": "", - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 0, - "set_only_once": 0, - "translatable": 0, - "unique": 0 + "fieldtype": "Column Break" }, { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, - "default": "", "fieldname": "email", "fieldtype": "Data", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 0, - "in_standard_filter": 0, "label": "Email", - "length": 0, - "no_copy": 0, - "options": "User", - "permlevel": 0, - "precision": "", - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 0, - "set_only_once": 0, - "translatable": 0, - "unique": 0 + "options": "User" }, { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, "fieldname": "conference_details_section", "fieldtype": "Section Break", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 0, - "in_standard_filter": 0, - "label": "Conference Details", - "length": 0, - "no_copy": 0, - "permlevel": 0, - "precision": "", - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 0, - "set_only_once": 0, - "translatable": 0, - "unique": 0 + "label": "Conference Details" }, { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, - "default": "", - "fieldname": "conference", - "fieldtype": "Select", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 0, - "in_standard_filter": 0, - "label": "Conference", - "length": 0, - "no_copy": 0, - "options": "\n2017\n2018", - "permlevel": 0, - "precision": "", - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 0, - "set_only_once": 0, - "translatable": 0, - "unique": 0 - }, + "fieldname": "conference", + "fieldtype": "Select", + "label": "Conference", + "options": "\n2017\n2018" + }, { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, - "fieldname": "full_conference_tickets", - "fieldtype": "Int", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 0, - "in_standard_filter": 0, - "label": "Full Conference Tickets", - "length": 0, - "no_copy": 0, - "permlevel": 0, - "precision": "", - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 0, - "set_only_once": 0, - "translatable": 0, - "unique": 0 - }, + "fieldname": "full_conference_tickets", + "fieldtype": "Int", + "label": "Full Conference Tickets" + }, { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, - "fieldname": "user_conference_tickets", - "fieldtype": "Int", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 0, - "in_standard_filter": 0, - "label": "User Conference Tickets", - "length": 0, - "no_copy": 0, - "permlevel": 0, - "precision": "", - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 0, - "set_only_once": 0, - "translatable": 0, - "unique": 0 - }, + "fieldname": "user_conference_tickets", + "fieldtype": "Int", + "label": "User Conference Tickets" + }, { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, + "default": "0", "fieldname": "paid", "fieldtype": "Check", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 0, - "in_standard_filter": 0, - "label": "Paid", - "length": 0, - "no_copy": 0, - "permlevel": 0, - "precision": "", - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 0, - "set_only_once": 0, - "translatable": 0, - "unique": 0 + "label": "Paid" }, { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, "fieldname": "column_break_10", - "fieldtype": "Column Break", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 0, - "in_standard_filter": 0, - "length": 0, - "no_copy": 0, - "permlevel": 0, - "precision": "", - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 0, - "set_only_once": 0, - "translatable": 0, - "unique": 0 - }, + "fieldtype": "Column Break" + }, { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, "fieldname": "tshirt_size", - "fieldtype": "Select", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 0, - "in_standard_filter": 0, + "fieldtype": "Select", "label": "T-Shirt Size", - "length": 0, - "no_copy": 0, - "options": "S\nM\nL\nXL\nXXL\nXXXL", - "permlevel": 0, - "precision": "", - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 0, - "set_only_once": 0, - "translatable": 0, - "unique": 0 - }, + "options": "S\nM\nL\nXL\nXXL\nXXXL" + }, { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, "fieldname": "currency", "fieldtype": "Select", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 1, - "in_standard_filter": 0, + "in_list_view": 1, "label": "Currency", - "length": 0, - "no_copy": 0, "options": "USD\nINR", - "permlevel": 0, - "precision": "", - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 1, - "search_index": 0, - "set_only_once": 0, - "translatable": 0, - "unique": 0 - }, + "reqd": 1 + }, { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, "fieldname": "amount", "fieldtype": "Currency", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, "in_list_view": 1, - "in_standard_filter": 0, "label": "Amount", - "length": 0, - "no_copy": 0, - "permlevel": 0, - "precision": "", - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 1, - "search_index": 0, - "set_only_once": 0, - "translatable": 0, - "unique": 0 - }, + "reqd": 1 + }, { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, - "fieldname": "thank_you_email_sent", - "fieldtype": "Check", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 0, - "in_standard_filter": 0, - "label": "Thank You Email Sent", - "length": 0, - "no_copy": 0, - "permlevel": 0, - "precision": "", - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 0, - "set_only_once": 0, - "translatable": 0, - "unique": 0 + "default": "0", + "fieldname": "thank_you_email_sent", + "fieldtype": "Check", + "label": "Thank You Email Sent" + }, + { + "fieldname": "tshirt_table", + "fieldtype": "Table", + "label": "T-Shirt Sizes", + "options": "TShirt Sizes" } - ], - "has_web_view": 0, - "hide_heading": 0, - "hide_toolbar": 0, - "idx": 0, - "image_view": 0, - "in_create": 0, - "is_submittable": 0, - "issingle": 0, - "istable": 0, - "max_attachments": 0, - "modified": "2018-10-02 12:44:37.868959", - "modified_by": "Administrator", - "module": "ERPNext Foundation", - "name": "Conference Participant", - "name_case": "", - "owner": "Administrator", + ], + "modified": "2019-08-02 10:29:22.188416", + "modified_by": "Administrator", + "module": "ERPNext Foundation", + "name": "Conference Participant", + "owner": "Administrator", "permissions": [ { - "amend": 0, - "cancel": 0, - "create": 1, - "delete": 1, - "email": 1, - "export": 1, - "if_owner": 0, - "import": 0, - "permlevel": 0, - "print": 1, - "read": 1, - "report": 1, - "role": "System Manager", - "set_user_permissions": 0, - "share": 1, - "submit": 0, + "create": 1, + "delete": 1, + "email": 1, + "export": 1, + "print": 1, + "read": 1, + "report": 1, + "role": "System Manager", + "share": 1, "write": 1 } - ], - "quick_entry": 1, - "read_only": 0, - "read_only_onload": 0, - "show_name_in_global_search": 0, - "sort_field": "modified", - "sort_order": "DESC", - "track_changes": 1, - "track_seen": 0, - "track_views": 0 + ], + "quick_entry": 1, + "sort_field": "modified", + "sort_order": "DESC", + "track_changes": 1 } \ No newline at end of file diff --git a/foundation/erpnext_foundation/doctype/tshirt_sizes/__init__.py b/foundation/erpnext_foundation/doctype/tshirt_sizes/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/foundation/erpnext_foundation/doctype/tshirt_sizes/tshirt_sizes.json b/foundation/erpnext_foundation/doctype/tshirt_sizes/tshirt_sizes.json new file mode 100644 index 00000000..c204aeda --- /dev/null +++ b/foundation/erpnext_foundation/doctype/tshirt_sizes/tshirt_sizes.json @@ -0,0 +1,38 @@ +{ + "creation": "2019-08-02 10:28:32.354345", + "doctype": "DocType", + "editable_grid": 1, + "engine": "InnoDB", + "field_order": [ + "size", + "quantity" + ], + "fields": [ + { + "fieldname": "size", + "fieldtype": "Select", + "in_list_view": 1, + "label": "Size", + "options": "S\nM\nL\nXL\nXXL\nXXXL", + "reqd": 1 + }, + { + "fieldname": "quantity", + "fieldtype": "Int", + "in_list_view": 1, + "label": "Quantity", + "reqd": 1 + } + ], + "istable": 1, + "modified": "2019-08-02 10:29:40.258477", + "modified_by": "Administrator", + "module": "ERPNext Foundation", + "name": "TShirt Sizes", + "owner": "Administrator", + "permissions": [], + "quick_entry": 1, + "sort_field": "modified", + "sort_order": "DESC", + "track_changes": 1 +} \ No newline at end of file diff --git a/foundation/erpnext_foundation/doctype/tshirt_sizes/tshirt_sizes.py b/foundation/erpnext_foundation/doctype/tshirt_sizes/tshirt_sizes.py new file mode 100644 index 00000000..7f898794 --- /dev/null +++ b/foundation/erpnext_foundation/doctype/tshirt_sizes/tshirt_sizes.py @@ -0,0 +1,10 @@ +# -*- coding: utf-8 -*- +# Copyright (c) 2019, EOSSF and contributors +# For license information, please see license.txt + +from __future__ import unicode_literals +# import frappe +from frappe.model.document import Document + +class TShirtSizes(Document): + pass diff --git a/foundation/erpnext_foundation/web_form/buy_tickets_inr/buy_tickets_inr.js b/foundation/erpnext_foundation/web_form/buy_tickets_inr/buy_tickets_inr.js index a00a71d3..c260e4d6 100644 --- a/foundation/erpnext_foundation/web_form/buy_tickets_inr/buy_tickets_inr.js +++ b/foundation/erpnext_foundation/web_form/buy_tickets_inr/buy_tickets_inr.js @@ -2,16 +2,40 @@ frappe.ready(function() { // bind events here frappe._calculate = function() { frappe.web_form.set_value('amount', - parseInt(frappe.web_form.get_value('full_conference_tickets') || 0) * 4000 + parseInt(frappe.web_form.get_value('full_conference_tickets') || 0) * 5000 ) }; - setTimeout(() => { + $('.btn-form-submit').hide(); + + frappe.web_form.events.on('after_load', () => { + frappe.web_form.set_df_property('tshirt_table', 'hidden', 1); $('input[data-fieldname="full_conference_tickets"]').on('keyup', function() { frappe._calculate(); + let value = frappe.web_form.get_value('full_conference_tickets') + console.log(value) + if (value > 1) { + frappe.web_form.set_df_property('tshirt_table', 'hidden', 0); + frappe.web_form.set_df_property('tshirt_size', 'hidden', 1); + } else { + frappe.web_form.set_df_property('tshirt_table', 'hidden', 1); + frappe.web_form.set_df_property('tshirt_size', 'hidden', 0); + + } }); frappe._calculate(); - }, 1000); + }) - $('.btn-form-submit').hide(); + frappe.web_form.validate = () => { + let tickets = frappe.web_form.get_value('full_conference_tickets'); + if (tickets > 1) { + tshirts = frappe.web_form.fields_dict.tshirt_table.get_value(); + total_tees = tshirts.reduce(function (acc, obj) { return acc + obj.quantity; }, 0); + if (total_tees > tickets) { + frappe.throw(`You can only choose ${tickets} T-Shirts.`) + } else if (total_tees < tickets) { + frappe.throw(`You have selected sizes for only ${total_tees} T-Shirts, you can choose ${tickets - total_tees} more`) + } + } + } }) \ No newline at end of file diff --git a/foundation/erpnext_foundation/web_form/buy_tickets_inr/buy_tickets_inr.json b/foundation/erpnext_foundation/web_form/buy_tickets_inr/buy_tickets_inr.json index aedd11a9..040089db 100644 --- a/foundation/erpnext_foundation/web_form/buy_tickets_inr/buy_tickets_inr.json +++ b/foundation/erpnext_foundation/web_form/buy_tickets_inr/buy_tickets_inr.json @@ -1,102 +1,118 @@ { - "accept_payment": 1, - "allow_comments": 0, - "allow_delete": 0, - "allow_edit": 0, - "allow_incomplete": 0, - "allow_multiple": 1, - "allow_print": 1, - "amount": 0.0, - "amount_based_on_field": 1, - "amount_field": "amount", - "creation": "2017-07-06 16:25:22.393979", - "currency": "INR", - "doc_type": "Conference Participant", - "docstatus": 0, - "doctype": "Web Form", - "idx": 0, - "introduction_text": "", - "is_standard": 1, - "login_required": 1, - "max_attachment_size": 0, - "modified": "2018-10-25 11:55:10.928574", - "modified_by": "Administrator", - "module": "ERPNext Foundation", - "name": "buy-tickets-inr", - "owner": "Administrator", - "payment_button_label": "Buy Now", - "payment_gateway": "Razorpay", - "published": 0, - "route": "buy-tickets-inr", - "show_in_grid": 0, - "show_sidebar": 0, - "sidebar_items": [], - "success_url": "/conf/2017", - "title": "Buy Tickets INR", + "accept_payment": 1, + "allow_comments": 0, + "allow_delete": 0, + "allow_edit": 0, + "allow_incomplete": 0, + "allow_multiple": 1, + "allow_print": 1, + "amount": 0.0, + "amount_based_on_field": 1, + "amount_field": "amount", + "client_script": "", + "creation": "2017-07-06 16:25:22.393979", + "currency": "INR", + "doc_type": "Conference Participant", + "docstatus": 0, + "doctype": "Web Form", + "idx": 0, + "introduction_text": "", + "is_standard": 1, + "login_required": 1, + "max_attachment_size": 0, + "modified": "2019-08-02 10:31:22.359552", + "modified_by": "Administrator", + "module": "ERPNext Foundation", + "name": "buy-tickets-inr", + "owner": "Administrator", + "payment_button_label": "Buy Now", + "payment_gateway": "Razorpay", + "published": 1, + "route": "buy-tickets-inr", + "route_to_success_link": 0, + "show_attachments": 0, + "show_in_grid": 0, + "show_sidebar": 0, + "sidebar_items": [], + "success_url": "/conf/2017", + "title": "Buy Tickets INR", "web_form_fields": [ { - "allow_read_on_all_link_options": 0, - "fieldname": "participant_name", - "fieldtype": "Data", - "hidden": 0, - "label": "Participant Name", - "max_length": 0, - "max_value": 0, - "read_only": 0, - "reqd": 1, + "allow_read_on_all_link_options": 0, + "fieldname": "participant_name", + "fieldtype": "Data", + "hidden": 0, + "label": "Participant Name", + "max_length": 0, + "max_value": 0, + "read_only": 0, + "reqd": 1, "show_in_filter": 0 - }, + }, { - "allow_read_on_all_link_options": 0, - "description": "Rs 4000 per person. Includes lunch and dinner on both days", - "fieldname": "full_conference_tickets", - "fieldtype": "Int", - "hidden": 0, - "label": "No of Tickets", - "max_length": 0, - "max_value": 0, - "read_only": 0, - "reqd": 0, + "allow_read_on_all_link_options": 0, + "description": "Rs 4000 per person. Includes lunch and dinner on both days", + "fieldname": "full_conference_tickets", + "fieldtype": "Int", + "hidden": 0, + "label": "No of Tickets", + "max_length": 0, + "max_value": 0, + "read_only": 0, + "reqd": 0, "show_in_filter": 0 - }, + }, { - "allow_read_on_all_link_options": 0, - "fieldname": "tshirt_size", - "fieldtype": "Select", - "hidden": 0, - "label": "T-Shirt Size", - "max_length": 0, - "max_value": 0, - "options": "S\nM\nL\nXL\nXXL\nXXXL", - "read_only": 0, - "reqd": 0, + "allow_read_on_all_link_options": 0, + "fieldname": "tshirt_table", + "fieldtype": "Table", + "hidden": 0, + "label": "T-Shirt Sizes", + "max_length": 0, + "max_value": 0, + "options": "TShirt Sizes", + "read_only": 0, + "reqd": 0, "show_in_filter": 0 - }, + }, { - "allow_read_on_all_link_options": 0, - "default": "INR", - "fieldname": "currency", - "fieldtype": "Select", - "hidden": 0, - "label": "Currency", - "max_length": 0, - "max_value": 0, - "options": "INR", - "read_only": 1, - "reqd": 1, + "allow_read_on_all_link_options": 0, + "fieldname": "tshirt_size", + "fieldtype": "Select", + "hidden": 0, + "label": "T-Shirt Size", + "max_length": 0, + "max_value": 0, + "options": "S\nM\nL\nXL\nXXL\nXXXL", + "read_only": 0, + "reqd": 0, "show_in_filter": 0 - }, + }, { - "allow_read_on_all_link_options": 0, - "fieldname": "amount", - "fieldtype": "Data", - "hidden": 0, - "label": "Amount", - "max_length": 0, - "max_value": 0, - "read_only": 1, - "reqd": 1, + "allow_read_on_all_link_options": 0, + "default": "INR", + "fieldname": "currency", + "fieldtype": "Select", + "hidden": 0, + "label": "Currency", + "max_length": 0, + "max_value": 0, + "options": "INR", + "read_only": 1, + "reqd": 1, + "show_in_filter": 0 + }, + { + "allow_read_on_all_link_options": 0, + "fieldname": "amount", + "fieldtype": "Data", + "hidden": 0, + "label": "Amount", + "max_length": 0, + "max_value": 0, + "read_only": 1, + "reqd": 1, "show_in_filter": 0 } ] -} +} \ No newline at end of file diff --git a/foundation/erpnext_foundation/web_form/buy_tickets_paypal/buy_tickets_paypal.js b/foundation/erpnext_foundation/web_form/buy_tickets_paypal/buy_tickets_paypal.js index d3ac315b..42a26b09 100644 --- a/foundation/erpnext_foundation/web_form/buy_tickets_paypal/buy_tickets_paypal.js +++ b/foundation/erpnext_foundation/web_form/buy_tickets_paypal/buy_tickets_paypal.js @@ -6,12 +6,36 @@ frappe.ready(function() { ) }; - setTimeout(() => { + $('.btn-form-submit').hide(); + + frappe.web_form.events.on('after_load', () => { + frappe.web_form.set_df_property('tshirt_table', 'hidden', 1); $('input[data-fieldname="full_conference_tickets"]').on('keyup', function() { frappe._calculate(); + let value = frappe.web_form.get_value('full_conference_tickets') + console.log(value) + if (value > 1) { + frappe.web_form.set_df_property('tshirt_table', 'hidden', 0); + frappe.web_form.set_df_property('tshirt_size', 'hidden', 1); + } else { + frappe.web_form.set_df_property('tshirt_table', 'hidden', 1); + frappe.web_form.set_df_property('tshirt_size', 'hidden', 0); + + } }); frappe._calculate(); - }, 1000); + }) - $('.btn-form-submit').hide(); + frappe.web_form.validate = () => { + let tickets = frappe.web_form.get_value('full_conference_tickets'); + if (tickets > 1) { + tshirts = frappe.web_form.fields_dict.tshirt_table.get_value(); + total_tees = tshirts.reduce(function (acc, obj) { return acc + obj.quantity; }, 0); + if (total_tees > tickets) { + frappe.throw(`You can only choose ${tickets} T-Shirts.`) + } else if (total_tees < tickets) { + frappe.throw(`You have selected sizes for only ${total_tees} T-Shirts, you can choose ${tickets - total_tees} more`) + } + } + } }) \ No newline at end of file diff --git a/foundation/erpnext_foundation/web_form/buy_tickets_paypal/buy_tickets_paypal.json b/foundation/erpnext_foundation/web_form/buy_tickets_paypal/buy_tickets_paypal.json index ab9c06e6..539dfa1f 100644 --- a/foundation/erpnext_foundation/web_form/buy_tickets_paypal/buy_tickets_paypal.json +++ b/foundation/erpnext_foundation/web_form/buy_tickets_paypal/buy_tickets_paypal.json @@ -1,108 +1,123 @@ { - "accept_payment": 1, - "allow_comments": 0, - "allow_delete": 0, - "allow_edit": 0, - "allow_incomplete": 0, - "allow_multiple": 1, - "allow_print": 1, - "amount": 0.0, - "amount_based_on_field": 1, - "amount_field": "amount", - "creation": "2017-07-06 16:22:37.464680", - "currency": "USD", - "doc_type": "Conference Participant", - "docstatus": 0, - "doctype": "Web Form", - "idx": 0, - "introduction_text": "", - "is_standard": 1, - "login_required": 1, - "max_attachment_size": 0, - "modified": "2018-10-25 11:56:03.656894", - "modified_by": "Administrator", - "module": "ERPNext Foundation", - "name": "buy-tickets-paypal", - "owner": "Administrator", - "payment_button_label": "Buy Now", - "payment_gateway": "PayPal", - "published": 0, - "route": "buy-tickets-paypal", - "show_in_grid": 0, - "show_sidebar": 0, + "accept_payment": 1, + "allow_comments": 0, + "allow_delete": 0, + "allow_edit": 0, + "allow_incomplete": 0, + "allow_multiple": 1, + "allow_print": 1, + "amount": 0.0, + "amount_based_on_field": 1, + "amount_field": "amount", + "creation": "2017-07-06 16:22:37.464680", + "currency": "USD", + "doc_type": "Conference Participant", + "docstatus": 0, + "doctype": "Web Form", + "idx": 0, + "introduction_text": "", + "is_standard": 1, + "login_required": 1, + "max_attachment_size": 0, + "modified": "2019-08-02 14:37:44.247816", + "modified_by": "Administrator", + "module": "ERPNext Foundation", + "name": "buy-tickets-paypal", + "owner": "Administrator", + "payment_button_label": "Buy Now", + "payment_gateway": "PayPal", + "published": 1, + "route": "buy-tickets-paypal", + "route_to_success_link": 0, + "show_attachments": 0, + "show_in_grid": 0, + "show_sidebar": 0, "sidebar_items": [ { - "enabled": 1, - "route": "/buy-tickets-paypal", + "enabled": 1, + "route": "/buy-tickets-paypal", "title": "My Tickets" } - ], - "success_url": "/conf/2017", - "title": "Buy Tickets Paypal", + ], + "success_url": "/conf/2017", + "title": "Buy Tickets Paypal", "web_form_fields": [ { - "allow_read_on_all_link_options": 0, - "fieldname": "participant_name", - "fieldtype": "Data", - "hidden": 0, - "label": "Participant Name", - "max_length": 0, - "max_value": 0, - "read_only": 0, - "reqd": 1, + "allow_read_on_all_link_options": 0, + "fieldname": "participant_name", + "fieldtype": "Data", + "hidden": 0, + "label": "Participant Name", + "max_length": 0, + "max_value": 0, + "read_only": 0, + "reqd": 1, "show_in_filter": 0 - }, + }, { - "allow_read_on_all_link_options": 0, - "description": "$60 per person. Includes lunch and dinner on both days", - "fieldname": "full_conference_tickets", - "fieldtype": "Int", - "hidden": 0, - "label": "No of Tickets", - "max_length": 0, - "max_value": 0, - "read_only": 0, - "reqd": 0, + "allow_read_on_all_link_options": 0, + "description": "$60 per person. Includes lunch and dinner on both days", + "fieldname": "full_conference_tickets", + "fieldtype": "Int", + "hidden": 0, + "label": "No of Tickets", + "max_length": 0, + "max_value": 0, + "read_only": 0, + "reqd": 0, "show_in_filter": 0 - }, + }, { - "allow_read_on_all_link_options": 0, - "fieldname": "tshirt_size", - "fieldtype": "Select", - "hidden": 0, - "label": "T-Shirt Size", - "max_length": 0, - "max_value": 0, - "options": "S\nM\nL\nXL\nXXL\nXXXL", - "read_only": 0, - "reqd": 0, + "allow_read_on_all_link_options": 0, + "fieldname": "tshirt_table", + "fieldtype": "Table", + "hidden": 0, + "label": "T-Shirt Sizes", + "max_length": 0, + "max_value": 0, + "options": "TShirt Sizes", + "read_only": 0, + "reqd": 0, "show_in_filter": 0 - }, + }, { - "allow_read_on_all_link_options": 0, - "default": "USD", - "fieldname": "currency", - "fieldtype": "Select", - "hidden": 0, - "label": "Currency", - "max_length": 0, - "max_value": 0, - "options": "USD\nINR", - "read_only": 1, - "reqd": 1, + "allow_read_on_all_link_options": 0, + "fieldname": "tshirt_size", + "fieldtype": "Select", + "hidden": 0, + "label": "T-Shirt Size", + "max_length": 0, + "max_value": 0, + "options": "S\nM\nL\nXL\nXXL\nXXXL", + "read_only": 0, + "reqd": 0, "show_in_filter": 0 - }, + }, { - "allow_read_on_all_link_options": 0, - "fieldname": "amount", - "fieldtype": "Data", - "hidden": 0, - "label": "Amount", - "max_length": 0, - "max_value": 0, - "read_only": 1, - "reqd": 1, + "allow_read_on_all_link_options": 0, + "default": "USD", + "fieldname": "currency", + "fieldtype": "Select", + "hidden": 0, + "label": "Currency", + "max_length": 0, + "max_value": 0, + "options": "USD\nINR", + "read_only": 1, + "reqd": 1, + "show_in_filter": 0 + }, + { + "allow_read_on_all_link_options": 0, + "fieldname": "amount", + "fieldtype": "Data", + "hidden": 0, + "label": "Amount", + "max_length": 0, + "max_value": 0, + "read_only": 1, + "reqd": 1, "show_in_filter": 0 } ] -} +} \ No newline at end of file