Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion sinai_spark/hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
# page_js = {"page" : "public/js/file.js"}

# include js in doctype views
doctype_js = {"Sales Order" : "public/js/sales_order.js"}
doctype_js = {"Sales Invoice" : "public/js/sales_invoice.js"}
# doctype_list_js = {"doctype" : "public/js/doctype_list.js"}
# doctype_tree_js = {"doctype" : "public/js/doctype_tree.js"}
# doctype_calendar_js = {"doctype" : "public/js/doctype_calendar.js"}
Expand Down
8 changes: 8 additions & 0 deletions sinai_spark/public/js/sales_invoice.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
frappe.ui.form.on('Sales Invoice', {
refresh: function (frm) {
setTimeout(() => {
frm.remove_custom_button('Delivery', 'Create');
frm.remove_custom_button('Payment Request', 'Create');
}, 500);
}
});
4 changes: 3 additions & 1 deletion sinai_spark/sinai_spark/doctype/attachments/attachments.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"actions": [],
"allow_rename": 1,
"autoname": ".#####",
"creation": "2025-01-23 10:32:39.868273",
"doctype": "DocType",
"editable_grid": 1,
Expand All @@ -19,10 +20,11 @@
"index_web_pages_for_search": 1,
"istable": 1,
"links": [],
"modified": "2025-01-23 10:34:47.862568",
"modified": "2025-01-25 10:22:30.556864",
"modified_by": "Administrator",
"module": "Sinai Spark",
"name": "Attachments",
"naming_rule": "Expression (old style)",
"owner": "Administrator",
"permissions": [],
"sort_field": "modified",
Expand Down
130 changes: 123 additions & 7 deletions sinai_spark/sinai_spark/doctype/business_proposal/business_proposal.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,129 @@ frappe.ui.form.on("Business Proposal", {
});
}, __("Change Status"));




},
status: function(frm) {
if (frm.doc.status === "Under Negotiation") {
frappe.confirm(
'The status is set to "Under Negotiation". Do you want to Send E-mail?',
function() {
// User confirmed, proceed to send the email
frappe.call({
method: 'sinai_spark.sinai_spark.doctype.business_proposal.business_proposal.send_mail_to_hr',
args: {
docname: frm.doc.name
},
callback: function(response) {
if (response.message === 'success') {
frappe.msgprint(__('Email sent to HR successfully.'));
} else {
frappe.msgprint(__('Failed to send email. Please try again.'));
}
}
});
},
function() {

}
);
}
else if (frm.doc.status === "Pending") {
frappe.confirm(
'The status is set to "Pending". Do you want to Send E-mail?',
function() {
// User confirmed, proceed to send the email
frappe.call({
method: 'sinai_spark.sinai_spark.doctype.business_proposal.business_proposal.send_mail_to_hr',
args: {
docname: frm.doc.name
},
callback: function(response) {
if (response.message === 'success') {
frappe.msgprint(__('Email sent to HR successfully.'));
} else {
frappe.msgprint(__('Failed to send email. Please try again.'));
}
}
});
},
function() {

}
);
}
else if (frm.doc.status === "Proposal Sent") {
frappe.confirm(
'The status is set to "Proposal Sent". Do you want to Send E-mail?',
function() {
// User confirmed, proceed to send the email
frappe.call({
method: 'sinai_spark.sinai_spark.doctype.business_proposal.business_proposal.send_mail_to_hr',
args: {
docname: frm.doc.name
},
callback: function(response) {
if (response.message === 'success') {
frappe.msgprint(__('Email sent to HR successfully.'));
} else {
frappe.msgprint(__('Failed to send email. Please try again.'));
}
}
});
},
function() {

}
);
}
else if (frm.doc.status === "Completed") {
frappe.confirm(
'The status is set to "Completed". Do you want to Send E-mail?',
function() {
// User confirmed, proceed to send the email
frappe.call({
method: 'sinai_spark.sinai_spark.doctype.business_proposal.business_proposal.send_mail_to_hr',
args: {
docname: frm.doc.name
},
callback: function(response) {
if (response.message === 'success') {
frappe.msgprint(__('Email sent to HR successfully.'));
} else {
frappe.msgprint(__('Failed to send email. Please try again.'));
}
}
});
},
function() {

}
);
}
else if (frm.doc.status === "Rejected") {
frappe.confirm(
'The status is set to "Rejected". Do you want to Send E-mail?',
function() {
// User confirmed, proceed to send the email
frappe.call({
method: 'sinai_spark.sinai_spark.doctype.business_proposal.business_proposal.send_mail_to_hr',
args: {
docname: frm.doc.name
},
callback: function(response) {
if (response.message === 'success') {
frappe.msgprint(__('Email sent to HR successfully.'));
} else {
frappe.msgprint(__('Failed to send email. Please try again.'));
}
}
});
},
function() {

}
);
}
}

});
//////////////////////////////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -170,7 +289,4 @@ frappe.ui.form.on("Business Proposal Item","business_proposal_item_remove",funct
frm.set_value('total_amount',total)
frm.refresh_field("total_amount")

});


////////////////////////////////////////////////////////////////////////////////////////////////////
});
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
"reference_details_section",
"column_break_ezqe",
"enquiry",
"column_break_skqx",
"connections_tab"
],
"fields": [
Expand Down Expand Up @@ -141,10 +140,6 @@
"fieldname": "remarks",
"fieldtype": "Small Text",
"label": "Remarks"
},
{
"fieldname": "column_break_skqx",
"fieldtype": "Column Break"
}
],
"index_web_pages_for_search": 1,
Expand All @@ -155,7 +150,7 @@
"link_fieldname": "business_proposal__id"
}
],
"modified": "2025-01-23 16:01:50.930166",
"modified": "2024-10-22 17:02:45.819473",
"modified_by": "Administrator",
"module": "Sinai Spark",
"name": "Business Proposal",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -211,3 +211,74 @@ def get_change(status, docname):
# # Commit the changes to the database
# frappe.db.commit()
# return True

@frappe.whitelist()
def send_mail_to_hr(docname):
try:
# Fetch the document
doc = frappe.get_doc("Business Proposal", docname)

# Fetch HR email(s) from Has Role
role = frappe.db.get_value("Sinai Spark Settings", None, "role")

if not role:
return frappe.throw("No HR Manager's email found in the system.")

# Email details
if doc.status == "Under Negotiation":
subject = f"Business Proposal {doc.name} is Under Negotiation"
message = f"""
Hello Team,<br><br>
The business proposal <b>{doc.name}</b> has been moved to the status <b>Under Negotiation</b>.<br>
Please review the details and take necessary action.<br><br>
Regards,<br>
System Notification
"""
elif doc.status == "Pending":
subject = f"Business Proposal {doc.name} is Pending"
message = f"""
Hello Team,<br><br>
The business proposal <b>{doc.name}</b> has been moved to the status <b>Pending</b>.<br>
Please review the details and take necessary action.<br><br>
Regards,<br>
System Notification
"""
elif doc.status == "Proposal Sent":
subject = f"Business Proposal {doc.name} is Proposal Sent"
message = f"""
Hello Team,<br><br>
The business proposal <b>{doc.name}</b> has been moved to the status <b>Proposal Sent</b>.<br>
Please review the details and take necessary action.<br><br>
Regards,<br>
System Notification
"""
elif doc.status == "Completed":
subject = f"Business Proposal {doc.name} is Completed"
message = f"""
Hello Team,<br><br>
The business proposal <b>{doc.name}</b> has been moved to the status <b>Completed</b>.<br>
Please review the details and take necessary action.<br><br>
Regards,<br>
System Notification
"""
elif doc.status == "Rejected":
subject = f"Business Proposal {doc.name} is Rejected"
message = f"""
Hello Team,<br><br>
The business proposal <b>{doc.name}</b> has been moved to the status <b>Rejected</b>.<br>
Please review the details and take necessary action.<br><br>
Regards,<br>
System Notification
"""

# Send email
frappe.sendmail(
recipients=role,
subject=subject,
message=message,
)
return "success"

except Exception as e:
frappe.log_error(frappe.get_traceback(), "Business Proposal Email Error")
return "error"
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from __future__ import unicode_literals
from frappe import _

def get_data():
return {
'heatmap': True,
Expand All @@ -20,4 +19,3 @@ def get_data():
"Enquiry": "enquiry"
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
"field_order": [
"document_expiry_item",
"column_break_aovz",
"document_expiry_date"
"document_expiry_date",
"attach"
],
"fields": [
{
Expand All @@ -29,12 +30,17 @@
{
"fieldname": "column_break_aovz",
"fieldtype": "Column Break"
},
{
"fieldname": "attach",
"fieldtype": "Attach",
"label": "Attach"
}
],
"index_web_pages_for_search": 1,
"istable": 1,
"links": [],
"modified": "2024-06-20 08:49:02.844641",
"modified": "2025-01-28 14:29:39.708571",
"modified_by": "Administrator",
"module": "Sinai Spark",
"name": "Document Expiry Details",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
"doctype": "DocType",
"engine": "InnoDB",
"field_order": [
"details_tab",
"section_break_gkzo",
"column_break_bybw",
"customer",
"remarks",
"column_break_sjbn",
Expand Down Expand Up @@ -36,6 +37,14 @@
"connections_tab"
],
"fields": [
{
"fieldname": "section_break_gkzo",
"fieldtype": "Section Break"
},
{
"fieldname": "column_break_bybw",
"fieldtype": "Column Break"
},
{
"fieldname": "column_break_sjbn",
"fieldtype": "Column Break"
Expand Down Expand Up @@ -202,17 +211,21 @@
"fieldtype": "Table",
"label": "Document Expiry Details",
"options": "Document Expiry Details"
},
{
"fieldname": "details_tab",
"fieldtype": "Tab Break",
"label": "Details"
}
],
"index_web_pages_for_search": 1,
"is_submittable": 1,
"links": [],
"modified": "2025-01-23 15:24:25.547253",
"links": [
{
"link_doctype": "Sales Order",
"link_fieldname": "custom_document_receiving"
},
{
"link_doctype": "Company Formation",
"link_fieldname": "document_receiving"
}
],
"modified": "2024-06-20 08:39:33.948469",
"modified_by": "Administrator",
"module": "Sinai Spark",
"name": "Document Receiving",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@

from frappe import _

def get_data():
return {
"fieldname": "business_proposal__id",
Expand Down
Loading