Added submit fucntionality
diff --git a/erpnext/www/book-appointment/index.js b/erpnext/www/book-appointment/index.js
index 1482c51..e1a2338 100644
--- a/erpnext/www/book-appointment/index.js
+++ b/erpnext/www/book-appointment/index.js
@@ -80,7 +80,7 @@
console.log(slots)
if (slots.length <= 0) {
let message_div = document.createElement('p');
-
+
message_div.innerHTML = "There are no slots available on this date";
timeslot_container.appendChild(message_div);
}
@@ -134,7 +134,7 @@
time_span.innerHTML = time_div.id
}
-function submit() {
+async function submit() {
var date = document.getElementById('appointment-date').value;
var time = document.getElementsByClassName('selected')[0].id;
contact = {};
@@ -143,4 +143,13 @@
contact.skype = document.getElementById('customer_skype').value;
contact.notes = document.getElementById('customer_notes').value;
console.log({ date, time, contact });
+ let abc = (await frappe.call({
+ method: 'erpnext.www.book-appointment.index.create_appointment',
+ args: {
+ 'date': date,
+ 'time': time,
+ 'contact': contact
+ }
+ })).message;
+ console.log(abc)
}
diff --git a/erpnext/www/book-appointment/index.py b/erpnext/www/book-appointment/index.py
index 15d5f9a..340f3ad 100644
--- a/erpnext/www/book-appointment/index.py
+++ b/erpnext/www/book-appointment/index.py
@@ -1,5 +1,6 @@
import frappe
import datetime
+import json
@frappe.whitelist(allow_guest=True)
def get_appointment_settings():
@@ -68,10 +69,18 @@
@frappe.whitelist(allow_guest=True)
def create_appointment(date,time,contact):
-
- appointment = frappe.frappe.get_doc('Appointment')
- appointment.scheduled_time = date
+ appointment = frappe.new_doc('Appointment')
+ format_string = '%Y-%m-%d %H:%M:%S'
+ appointment.scheduled_time = datetime.datetime.strptime(date+" "+time,format_string)
+ contact = json.loads(contact)
+ appointment.customer_name = contact['name']
+ appointment.customer_phone_no = contact['number']
+ appointment.customer_skype = contact['skype']
+ appointment.customer_details = contact['notes']
+ appointment.insert()
+
+# Helper Functions
def filter_timeslots(date,timeslots):
filtered_timeslots = []
for timeslot in timeslots:
@@ -82,8 +91,6 @@
def check_availabilty(timeslot,settings):
return frappe.db.count('Appointment',{'scheduled_time':timeslot})<settings.number_of_agents
-
-
def _is_holiday(date, holiday_list):
for holiday in holiday_list.holidays:
if holiday.holiday_date == date: