Added submit fucntionality
This commit is contained in:
parent
a3d04cdbca
commit
c5b2a58669
@ -134,7 +134,7 @@ function initialise_enter_details() {
|
|||||||
time_span.innerHTML = time_div.id
|
time_span.innerHTML = time_div.id
|
||||||
}
|
}
|
||||||
|
|
||||||
function submit() {
|
async function submit() {
|
||||||
var date = document.getElementById('appointment-date').value;
|
var date = document.getElementById('appointment-date').value;
|
||||||
var time = document.getElementsByClassName('selected')[0].id;
|
var time = document.getElementsByClassName('selected')[0].id;
|
||||||
contact = {};
|
contact = {};
|
||||||
@ -143,4 +143,13 @@ function submit() {
|
|||||||
contact.skype = document.getElementById('customer_skype').value;
|
contact.skype = document.getElementById('customer_skype').value;
|
||||||
contact.notes = document.getElementById('customer_notes').value;
|
contact.notes = document.getElementById('customer_notes').value;
|
||||||
console.log({ date, time, contact });
|
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 frappe
|
||||||
import datetime
|
import datetime
|
||||||
|
import json
|
||||||
|
|
||||||
@frappe.whitelist(allow_guest=True)
|
@frappe.whitelist(allow_guest=True)
|
||||||
def get_appointment_settings():
|
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)
|
@frappe.whitelist(allow_guest=True)
|
||||||
def create_appointment(date,time,contact):
|
def create_appointment(date,time,contact):
|
||||||
|
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()
|
||||||
|
|
||||||
appointment = frappe.frappe.get_doc('Appointment')
|
|
||||||
appointment.scheduled_time = date
|
|
||||||
|
|
||||||
|
# Helper Functions
|
||||||
def filter_timeslots(date,timeslots):
|
def filter_timeslots(date,timeslots):
|
||||||
filtered_timeslots = []
|
filtered_timeslots = []
|
||||||
for timeslot in timeslots:
|
for timeslot in timeslots:
|
||||||
@ -82,8 +91,6 @@ def filter_timeslots(date,timeslots):
|
|||||||
def check_availabilty(timeslot,settings):
|
def check_availabilty(timeslot,settings):
|
||||||
return frappe.db.count('Appointment',{'scheduled_time':timeslot})<settings.number_of_agents
|
return frappe.db.count('Appointment',{'scheduled_time':timeslot})<settings.number_of_agents
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def _is_holiday(date, holiday_list):
|
def _is_holiday(date, holiday_list):
|
||||||
for holiday in holiday_list.holidays:
|
for holiday in holiday_list.holidays:
|
||||||
if holiday.holiday_date == date:
|
if holiday.holiday_date == date:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user