Added submit fucntionality
This commit is contained in:
parent
a3d04cdbca
commit
c5b2a58669
@ -80,7 +80,7 @@ async function navigate_to_time_select() {
|
||||
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 @@ function initialise_enter_details() {
|
||||
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 @@ function submit() {
|
||||
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)
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
import frappe
|
||||
import datetime
|
||||
import json
|
||||
|
||||
@frappe.whitelist(allow_guest=True)
|
||||
def get_appointment_settings():
|
||||
@ -68,10 +69,18 @@ def get_available_slots_between(query_start_time, query_end_time, settings):
|
||||
|
||||
@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 filter_timeslots(date,timeslots):
|
||||
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:
|
||||
|
Loading…
x
Reference in New Issue
Block a user