Add lead and calender event to appointments
This commit is contained in:
parent
8051ca1859
commit
a2dbd391b3
@ -11,7 +11,9 @@
|
||||
"customer_name",
|
||||
"customer_phone_number",
|
||||
"customer_skype",
|
||||
"customer_details"
|
||||
"customer_details",
|
||||
"lead",
|
||||
"calender_event"
|
||||
],
|
||||
"fields": [
|
||||
{
|
||||
@ -56,9 +58,23 @@
|
||||
"label": "Status",
|
||||
"options": "Open\nClosed",
|
||||
"reqd": 1
|
||||
},
|
||||
{
|
||||
"fieldname": "lead",
|
||||
"fieldtype": "Link",
|
||||
"label": "Lead",
|
||||
"options": "Lead",
|
||||
"reqd": 1
|
||||
},
|
||||
{
|
||||
"fieldname": "calender_event",
|
||||
"fieldtype": "Link",
|
||||
"label": "Calender Event",
|
||||
"options": "Event",
|
||||
"reqd": 1
|
||||
}
|
||||
],
|
||||
"modified": "2019-09-10 11:17:20.200603",
|
||||
"modified": "2019-09-12 10:42:47.841841",
|
||||
"modified_by": "Administrator",
|
||||
"module": "CRM",
|
||||
"name": "Appointment",
|
||||
|
@ -14,7 +14,7 @@ class Appointment(Document):
|
||||
if(number_of_appointments_in_same_slot>=settings.number_of_agents):
|
||||
frappe.throw('Time slot is not available')
|
||||
|
||||
def after_insert(self):
|
||||
def before_insert(self):
|
||||
appointment_event = frappe.new_doc('Event')
|
||||
appointment_event.subject = 'Appointment with ' + self.customer_name
|
||||
appointment_event.starts_on = self.scheduled_time
|
||||
@ -23,4 +23,5 @@ class Appointment(Document):
|
||||
settings = frappe.get_doc('Appointment Booking Settings')
|
||||
appointment_event.ends_on = self.scheduled_time + timedelta(minutes=settings.appointment_duration)
|
||||
appointment_event.insert()
|
||||
self.calender_event = appointment_event.name
|
||||
|
||||
|
@ -51,10 +51,12 @@
|
||||
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">
|
||||
<textarea class="form-control mt-3" name="customer_notes" id="customer_notes" cols="30" rows="10"
|
||||
placeholder="Notes"></textarea>
|
||||
<div class="row mt-3 ">
|
||||
<div class="col-md"><button class="btn btn-dark form-control" onclick="initialize_select_date()">Go back</button></div>
|
||||
<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>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -5,7 +5,7 @@ frappe.ready(() => {
|
||||
window.holiday_list = [];
|
||||
|
||||
async function initialise_select_date() {
|
||||
document.getElementById('enter-details').style.display = 'none';
|
||||
navigate_to_page(1);
|
||||
await get_global_variables();
|
||||
setup_date_picker();
|
||||
setup_timezone_selector();
|
||||
@ -115,7 +115,6 @@ async function update_time_slots(selected_date, selected_timezone) {
|
||||
timeslot_container.appendChild(timeslot_div);
|
||||
});
|
||||
set_default_timeslot();
|
||||
show_next_button();
|
||||
}
|
||||
|
||||
function clear_time_slots() {
|
||||
@ -146,6 +145,7 @@ function select_time() {
|
||||
window.selected_time = this.id
|
||||
selected_element.classList.remove("selected");
|
||||
this.classList.add("selected");
|
||||
show_next_button();
|
||||
}
|
||||
|
||||
function set_default_timeslot() {
|
||||
@ -159,11 +159,25 @@ function set_default_timeslot() {
|
||||
}
|
||||
}
|
||||
|
||||
function setup_details_page(){
|
||||
function navigate_to_page(page_number){
|
||||
let page1 = document.getElementById('select-date-time');
|
||||
let page2 = document.getElementById('enter-details');
|
||||
page1.style.display = 'none';
|
||||
page2.style.display = 'block';
|
||||
switch(page_number){
|
||||
case 1:
|
||||
page1.style.display = 'block';
|
||||
page2.style.display = 'none';
|
||||
break;
|
||||
case 2:
|
||||
page1.style.display = 'none';
|
||||
page2.style.display = 'block';
|
||||
break;
|
||||
default:
|
||||
console.log("That's not a valid page")
|
||||
}
|
||||
}
|
||||
|
||||
function setup_details_page(){
|
||||
navigate_to_page(2)
|
||||
let date_container = document.getElementsByClassName('date-span')[0];
|
||||
let time_container = document.getElementsByClassName('time-span')[0];
|
||||
date_container.innerHTML = moment(window.selected_date).format("MMM Do YYYY");
|
||||
@ -196,6 +210,7 @@ function form_validation(){
|
||||
contact.number = document.getElementById('customer_number').value;
|
||||
contact.skype = document.getElementById('customer_skype').value;
|
||||
contact.notes = document.getElementById('customer_notes').value;
|
||||
contact.email = document.getElementById('customer_email').value;
|
||||
window.contact = contact
|
||||
console.log({ date, time, contact });
|
||||
}
|
||||
|
@ -94,8 +94,16 @@ def create_appointment(date, time, contact):
|
||||
appointment.customer_skype = contact['skype']
|
||||
appointment.customer_details = contact['notes']
|
||||
appointment.status = 'Open'
|
||||
appointment.lead = find_lead_by_email(contact['email']).name
|
||||
appointment.insert()
|
||||
|
||||
def find_lead_by_email(email):
|
||||
if frappe.db.exists({
|
||||
'doctype':'Lead',
|
||||
'email_id':email
|
||||
}):
|
||||
return frappe.get_list('Lead',filters={'email_id':email})[0]
|
||||
frappe.throw('Email ID not associated with any Lead. Please make sure to use the email address you got this mail on')
|
||||
|
||||
# Helper Functions
|
||||
def filter_timeslots(date, timeslots):
|
||||
|
Loading…
x
Reference in New Issue
Block a user