Merge branch 'develop' of https://github.com/0Pranav/erpnext into develop
diff --git a/erpnext/crm/doctype/appointment/appointment.json b/erpnext/crm/doctype/appointment/appointment.json
index 22df5c6..323e096 100644
--- a/erpnext/crm/doctype/appointment/appointment.json
+++ b/erpnext/crm/doctype/appointment/appointment.json
@@ -35,14 +35,12 @@
   {
    "fieldname": "customer_phone_number",
    "fieldtype": "Data",
-   "label": "Phone Number",
-   "reqd": 1
+   "label": "Phone Number"
   },
   {
    "fieldname": "customer_skype",
    "fieldtype": "Data",
-   "label": "Skype ID",
-   "reqd": 1
+   "label": "Skype ID"
   },
   {
    "fieldname": "customer_details",
@@ -95,7 +93,7 @@
    "fieldtype": "Column Break"
   }
  ],
- "modified": "2019-09-23 10:57:04.876506",
+ "modified": "2019-09-25 13:08:46.368307",
  "modified_by": "Administrator",
  "module": "CRM",
  "name": "Appointment",
@@ -123,6 +121,29 @@
    "report": 1,
    "role": "Guest",
    "share": 1
+  },
+  {
+   "create": 1,
+   "delete": 1,
+   "email": 1,
+   "export": 1,
+   "print": 1,
+   "read": 1,
+   "report": 1,
+   "role": "Sales Manager",
+   "share": 1,
+   "write": 1
+  },
+  {
+   "create": 1,
+   "email": 1,
+   "export": 1,
+   "print": 1,
+   "read": 1,
+   "report": 1,
+   "role": "Sales User",
+   "share": 1,
+   "write": 1
   }
  ],
  "quick_entry": 1,
diff --git a/erpnext/crm/doctype/appointment/appointment.py b/erpnext/crm/doctype/appointment/appointment.py
index 2f14098..f32699e 100644
--- a/erpnext/crm/doctype/appointment/appointment.py
+++ b/erpnext/crm/doctype/appointment/appointment.py
@@ -33,12 +33,10 @@
 		self.lead = self.find_lead_by_email()
 
 	def after_insert(self):
-		# Auto assign
-		self.auto_assign()
-		# Check if lead was found 
 		if(self.lead):
 			# Create Calendar event
 			self.create_calendar_event()
+			self.auto_assign()
 		else:
 			# Set status to unverified
 			self.status = 'Unverified'
@@ -77,6 +75,7 @@
 		self.status = 'Open'
 		# Create calender event
 		self.create_calendar_event()
+		self.auto_assign()
 		self.save(ignore_permissions=True)
 		frappe.db.commit()
 
diff --git a/erpnext/crm/doctype/appointment/test_appointment.py b/erpnext/crm/doctype/appointment/test_appointment.py
index d529d37..bc7fe72 100644
--- a/erpnext/crm/doctype/appointment/test_appointment.py
+++ b/erpnext/crm/doctype/appointment/test_appointment.py
@@ -35,7 +35,7 @@
     return test_appointment
 
 class TestAppointment(unittest.TestCase):
-    test_appointment,test_lead = None
+    test_appointment = test_lead = None
     def setUp(self):
         test_lead = create_test_lead()
         test_appointment = test_create_test_appointments()
diff --git a/erpnext/crm/doctype/appointment_booking_settings/appointment_booking_settings.json b/erpnext/crm/doctype/appointment_booking_settings/appointment_booking_settings.json
index d72f577..4229e4b 100644
--- a/erpnext/crm/doctype/appointment_booking_settings/appointment_booking_settings.json
+++ b/erpnext/crm/doctype/appointment_booking_settings/appointment_booking_settings.json
@@ -65,7 +65,7 @@
   }
  ],
  "issingle": 1,
- "modified": "2019-09-19 12:36:34.011724",
+ "modified": "2019-09-25 13:08:28.328561",
  "modified_by": "Administrator",
  "module": "CRM",
  "name": "Appointment Booking Settings",
@@ -96,6 +96,16 @@
    "role": "HR Manager",
    "share": 1,
    "write": 1
+  },
+  {
+   "create": 1,
+   "delete": 1,
+   "email": 1,
+   "print": 1,
+   "read": 1,
+   "role": "Sales Manager",
+   "share": 1,
+   "write": 1
   }
  ],
  "quick_entry": 1,
diff --git a/erpnext/www/book-appointment/index.html b/erpnext/www/book-appointment/index.html
index 2e03213..1f6dd2e 100644
--- a/erpnext/www/book-appointment/index.html
+++ b/erpnext/www/book-appointment/index.html
@@ -45,16 +45,14 @@
     </div>
     <div class="row justify-content-center mt-3">
         <div class="col-md-4 align-items-center">
-            <input class="form-control mt-3" type="text" name="customer_name" id="customer_name" placeholder="Your Name"
-                required>
-            <input class="form-control mt-3" type="tel" name="customer_number" id="customer_number"
-                placeholder="Contact Number" required>
-            <input class="form-control mt-3" type="text" name="customer_skype" id="customer_skype" placeholder="Skype"
-                required>
-            <input class="form-control mt-3"type="email" name="customer_email" id="customer_email" 
-                placeholder="Email Address">
+            <form id="customer-form" action='#'>
+            <input class="form-control mt-3" type="text" name="customer_name" id="customer_name" placeholder="Your Name (required)"required>
+            <input class="form-control mt-3" type="tel" name="customer_number" id="customer_number" placeholder="+910000000000">
+            <input class="form-control mt-3" type="text" name="customer_skype" id="customer_skype" placeholder="Skype">
+            <input class="form-control mt-3"type="email" name="customer_email" id="customer_email" placeholder="Email Address (required)"required>
             <textarea class="form-control mt-3" name="customer_notes" id="customer_notes" cols="30" rows="10"
                 placeholder="Notes"></textarea>
+            </form>
             <div class="row mt-3 ">
                 <div class="col-md"><button class="btn btn-dark form-control" onclick="initialise_select_date()">Go back</button></div>
                 <div class="col-md"><button class="btn btn-primary form-control " onclick="submit()" id="submit-button">Submit</button></div>
diff --git a/erpnext/www/book-appointment/index.js b/erpnext/www/book-appointment/index.js
index 345e614..6034f4e 100644
--- a/erpnext/www/book-appointment/index.js
+++ b/erpnext/www/book-appointment/index.js
@@ -195,7 +195,11 @@
 }
 
 async function submit() {
-    // form validation here
+    let form = document.querySelector('#customer-form');
+    if(!form.checkValidity()){
+        form.reportValidity();
+        return;
+    }
     get_form_data();
     let appointment = (await frappe.call({
         method: 'erpnext.www.book-appointment.index.create_appointment',
@@ -212,6 +216,7 @@
 }
 
 function get_form_data() {
+    
     contact = {};
     contact.name = document.getElementById('customer_name').value;
     contact.number = document.getElementById('customer_number').value;
diff --git a/erpnext/www/book-appointment/verify/index.py b/erpnext/www/book-appointment/verify/index.py
index 86f9515..8ea9638 100644
--- a/erpnext/www/book-appointment/verify/index.py
+++ b/erpnext/www/book-appointment/verify/index.py
@@ -5,7 +5,7 @@
     if not verify_request():
         context.success = False
         return context
-    
+
     email = frappe.form_dict['email']
     appointment_name = frappe.form_dict['appointment']