[form] [legacy-js] removed old Dialog, PageHeader etc., cleanup Opportunity and Quotation

This commit is contained in:
Rushabh Mehta
2013-07-03 13:27:39 +05:30
parent 78979dca9b
commit 9a04b19160
9 changed files with 192 additions and 207 deletions

View File

@@ -55,18 +55,16 @@ cur_frm.cscript.refresh = function(doc,dt,dn) {
}
cur_frm.cscript.setup_dashboard = function(doc) {
cur_frm.layout.dashboard.empty().toggle(doc.__islocal ? false : true);
cur_frm.dashboard.reset(doc);
if(doc.__islocal)
return;
var headline = $('<div class="form-headline col col-lg-12">\
<span class="text-muted">Loading...</span></div>')
.appendTo(cur_frm.layout.dashboard);
cur_frm.dashboard.set_headline('<span class="text-muted">Loading...</span>')
cur_frm.layout.add_doctype_badge("Opportunity", "customer");
cur_frm.layout.add_doctype_badge("Quotation", "customer");
cur_frm.layout.add_doctype_badge("Sales Order", "customer");
cur_frm.layout.add_doctype_badge("Delivery Note", "customer");
cur_frm.layout.add_doctype_badge("Sales Invoice", "customer");
cur_frm.dashboard.add_doctype_badge("Opportunity", "customer");
cur_frm.dashboard.add_doctype_badge("Quotation", "customer");
cur_frm.dashboard.add_doctype_badge("Sales Order", "customer");
cur_frm.dashboard.add_doctype_badge("Delivery Note", "customer");
cur_frm.dashboard.add_doctype_badge("Sales Invoice", "customer");
wn.call({
type: "GET",
@@ -75,12 +73,13 @@ cur_frm.cscript.setup_dashboard = function(doc) {
customer: cur_frm.doc.name
},
callback: function(r) {
cur_frm.layout.dashboard.find(".form-headline")
.html(wn._("Total Billing This Year: ") + "<b>"
+ format_currency(r.message.total_billing, cur_frm.doc.default_currency)
+ '</b> / <span class="text-muted">' + wn._("Unpaid") + ": <b>" +
format_currency(r.message.total_unpaid, cur_frm.doc.default_currency) + '</b></span>');
cur_frm.layout.set_badge_count(r.message);
cur_frm.dashboard.set_headline(
wn._("Total Billing This Year: ") + "<b>"
+ format_currency(r.message.total_billing, cur_frm.doc.default_currency)
+ '</b> / <span class="text-muted">' + wn._("Unpaid") + ": <b>"
+ format_currency(r.message.total_unpaid, cur_frm.doc.default_currency)
+ '</b></span>');
cur_frm.dashboard.set_badge_count(r.message);
}
})
}

View File

@@ -40,9 +40,19 @@ erpnext.LeadController = wn.ui.form.Controller.extend({
},
refresh: function() {
var doc = this.frm.doc;
erpnext.hide_naming_series();
this.frm.clear_custom_buttons();
this.frm.dashboard.reset(doc);
if(!doc.__islocal) {
if(doc.status=="Converted") {
this.frm.dashboard.set_headline_alert(wn._("Converted"), "alert-success", "icon-ok-sign");
} else {
this.frm.dashboard.set_headline_alert(wn._(doc.status), "alert-info", "icon-exclamation-sign");
}
}
this.frm.__is_customer = this.frm.__is_customer || this.frm.doc.__is_customer;
if(!this.frm.doc.__islocal && !this.frm.__is_customer) {
this.frm.add_custom_button("Create Customer", this.frm.cscript['Create Customer']);

View File

@@ -18,9 +18,20 @@ wn.require('app/utilities/doctype/sms_control/sms_control.js');
cur_frm.cscript.refresh = function(doc, cdt, cdn){
erpnext.hide_naming_series();
cur_frm.dashboard.reset(doc);
if(!doc.__islocal) {
if(doc.status=="Converted" || doc.status=="Order Confirmed") {
cur_frm.dashboard.set_headline_alert(wn._(doc.status), "alert-success", "icon-ok-sign");
} else if(doc.status=="Opportunity Lost") {
cur_frm.dashboard.set_headline_alert(wn._(doc.status), "alert-danger", "icon-exclamation-sign");
} else {
cur_frm.dashboard.set_headline_alert(wn._(doc.status), "alert-info", "icon-exclamation-sign");
}
}
cur_frm.clear_custom_buttons();
if(doc.docstatus == 1) {
if(doc.docstatus === 1 && doc.status!=="Opportunity Lost") {
cur_frm.add_custom_button('Create Quotation', cur_frm.cscript['Create Quotation']);
cur_frm.add_custom_button('Opportunity Lost', cur_frm.cscript['Declare Opportunity Lost']);
cur_frm.add_custom_button('Send SMS', cur_frm.cscript.send_sms);
@@ -198,56 +209,35 @@ cur_frm.cscript['Create Quotation'] = function(){
// declare enquiry lost
//-------------------------
cur_frm.cscript['Declare Opportunity Lost'] = function(){
var e_lost_dialog;
var dialog = new wn.ui.Dialog({
title: "Set as Lost",
fields: [
{"fieldtype": "Text", "label": "Reason for losing", "fieldname": "reason",
"reqd": 1 },
{"fieldtype": "Button", "label": "Update", "fieldname": "update"},
]
});
set_e_lost_dialog = function(){
e_lost_dialog = new Dialog(400,150,'Add Opportunity Lost Reason');
e_lost_dialog.make_body([
['HTML', 'Message', '<div class="comment">Please add enquiry lost reason</div>'],
['Text', 'Opportunity Lost Reason'],
['HTML', 'Response', '<div class = "comment" id="update_enquiry_dialog_response"></div>'],
['HTML', 'Add Reason', '<div></div>']
]);
var add_reason_btn1 = $a($i(e_lost_dialog.widgets['Add Reason']), 'button', 'button');
add_reason_btn1.innerHTML = 'Add';
add_reason_btn1.onclick = function(){ e_lost_dialog.add(); }
var add_reason_btn2 = $a($i(e_lost_dialog.widgets['Add Reason']), 'button', 'button');
add_reason_btn2.innerHTML = 'Cancel';
$y(add_reason_btn2,{marginLeft:'4px'});
add_reason_btn2.onclick = function(){ e_lost_dialog.hide();}
e_lost_dialog.onshow = function() {
e_lost_dialog.widgets['Opportunity Lost Reason'].value = '';
$i('update_enquiry_dialog_response').innerHTML = '';
}
e_lost_dialog.add = function() {
// sending...
$i('update_enquiry_dialog_response').innerHTML = 'Processing...';
var arg = strip(e_lost_dialog.widgets['Opportunity Lost Reason'].value);
var call_back = function(r,rt) {
if(r.message == 'true'){
$i('update_enquiry_dialog_response').innerHTML = 'Done';
e_lost_dialog.hide();
cur_frm.refresh();
dialog.fields_dict.update.$input.click(function() {
args = dialog.get_values();
if(!args) return;
cur_frm.call({
doc: cur_frm.doc,
method: "declare_enquiry_lost",
args: args.reason,
callback: function(r) {
if(r.exc) {
msgprint("There were errors.");
return;
}
}
if(arg) {
$c_obj(make_doclist(cur_frm.doc.doctype, cur_frm.doc.name),'declare_enquiry_lost',arg,call_back);
}
else{
msgprint("Please add enquiry lost reason");
}
}
}
dialog.hide();
cur_frm.refresh();
},
btn: this
})
});
dialog.show();
if(!e_lost_dialog){
set_e_lost_dialog();
}
e_lost_dialog.show();
}
//get query select Territory

View File

@@ -36,10 +36,23 @@ erpnext.selling.QuotationController = erpnext.selling.SellingController.extend({
},
refresh: function(doc, dt, dn) {
this._super(doc, dt, dn);
cur_frm.dashboard.reset(doc);
if(!doc.__islocal) {
if(doc.status=="Converted" || doc.status=="Order Confirmed") {
cur_frm.dashboard.set_headline_alert(wn._(doc.status), "alert-success", "icon-ok-sign");
} else if(doc.status==="Order Lost") {
cur_frm.dashboard.set_headline_alert(wn._(doc.status), "alert-danger", "icon-exclamation-sign");
} else {
cur_frm.dashboard.set_headline_alert(wn._(doc.status), "alert-info", "icon-exclamation-sign");
}
}
if(doc.docstatus == 1 && doc.status!='Order Lost') {
if(doc.docstatus == 1 && doc.status!=='Order Lost') {
cur_frm.add_custom_button('Make Sales Order', cur_frm.cscript['Make Sales Order']);
cur_frm.add_custom_button('Set as Lost', cur_frm.cscript['Declare Order Lost']);
if(doc.status!=="Order Confirmed") {
cur_frm.add_custom_button('Set as Lost', cur_frm.cscript['Declare Order Lost']);
}
cur_frm.add_custom_button('Send SMS', cur_frm.cscript.send_sms);
}
@@ -150,51 +163,35 @@ cur_frm.cscript.pull_enquiry_detail = function(doc,cdt,cdn){
// declare order lost
//-------------------------
cur_frm.cscript['Declare Order Lost'] = function(){
var qtn_lost_dialog;
var dialog = new wn.ui.Dialog({
title: "Set as Lost",
fields: [
{"fieldtype": "Text", "label": "Reason for losing", "fieldname": "reason",
"reqd": 1 },
{"fieldtype": "Button", "label": "Update", "fieldname": "update"},
]
});
set_qtn_lost_dialog = function(){
qtn_lost_dialog = new Dialog(400,400,'Add Quotation Lost Reason');
qtn_lost_dialog.make_body([
['HTML', 'Message', '<div class="comment">Please add quotation lost reason</div>'],
['Text', 'Quotation Lost Reason'],
['HTML', 'Response', '<div class = "comment" id="update_quotation_dialog_response"></div>'],
['HTML', 'Add Reason', '<div></div>']
]);
var add_reason_btn1 = $a($i(qtn_lost_dialog.widgets['Add Reason']), 'button', 'button');
add_reason_btn1.innerHTML = 'Add';
add_reason_btn1.onclick = function(){ qtn_lost_dialog.add(); }
var add_reason_btn2 = $a($i(qtn_lost_dialog.widgets['Add Reason']), 'button', 'button');
add_reason_btn2.innerHTML = 'Cancel';
$y(add_reason_btn2,{marginLeft:'4px'});
add_reason_btn2.onclick = function(){ qtn_lost_dialog.hide();}
qtn_lost_dialog.onshow = function() {
qtn_lost_dialog.widgets['Quotation Lost Reason'].value = '';
$i('update_quotation_dialog_response').innerHTML = '';
}
qtn_lost_dialog.add = function() {
// sending...
$i('update_quotation_dialog_response').innerHTML = 'Processing...';
var arg = strip(qtn_lost_dialog.widgets['Quotation Lost Reason'].value);
var call_back = function(r,rt) {
if(r.message == 'true'){
$i('update_quotation_dialog_response').innerHTML = 'Done';
qtn_lost_dialog.hide();
cur_frm.refresh();
dialog.fields_dict.update.$input.click(function() {
args = dialog.get_values();
if(!args) return;
cur_frm.call({
method: "declare_order_lost",
doc: cur_frm.doc,
args: args.reason,
callback: function(r) {
if(r.exc) {
msgprint("There were errors.");
return;
}
}
if(arg) $c_obj(make_doclist(cur_frm.doc.doctype, cur_frm.doc.name),'declare_order_lost',arg,call_back);
else msgprint("Please add Quotation lost reason");
}
}
if(!qtn_lost_dialog){
set_qtn_lost_dialog();
}
qtn_lost_dialog.show();
dialog.hide();
cur_frm.refresh();
},
btn: this
})
});
dialog.show();
}
//================ Last Quoted Price and Last Sold Price suggestion ======================

View File

@@ -191,7 +191,7 @@ class DocType(SellingController):
# declare as order lost
#-------------------------
def declare_order_lost(self,arg):
def declare_order_lost(self, arg):
chk = sql("select t1.name from `tabSales Order` t1, `tabSales Order Item` t2 where t2.parent = t1.name and t1.docstatus=1 and t2.prevdoc_docname = %s",self.doc.name)
if chk:
msgprint("Sales Order No. "+cstr(chk[0][0])+" is submitted against this Quotation. Thus 'Order Lost' can not be declared against it.")

View File

@@ -2,7 +2,7 @@
{
"creation": "2013-05-24 19:29:08",
"docstatus": 0,
"modified": "2013-07-02 16:49:52",
"modified": "2013-07-03 11:54:11",
"modified_by": "Administrator",
"owner": "Administrator"
},
@@ -46,7 +46,8 @@
"doctype": "DocField",
"fieldname": "customer_section",
"fieldtype": "Section Break",
"label": "Customer"
"label": "Customer",
"options": "icon-user"
},
{
"doctype": "DocField",
@@ -117,17 +118,16 @@
"doctype": "DocField",
"fieldname": "customer_name",
"fieldtype": "Data",
"hidden": 0,
"hidden": 1,
"in_list_view": 1,
"label": "Customer Name",
"read_only": 1
},
{
"depends_on": "customer",
"doctype": "DocField",
"fieldname": "address_display",
"fieldtype": "Small Text",
"hidden": 0,
"hidden": 1,
"in_filter": 0,
"label": "Address",
"oldfieldname": "customer_address",
@@ -138,32 +138,29 @@
"search_index": 0
},
{
"depends_on": "customer",
"doctype": "DocField",
"fieldname": "contact_display",
"fieldtype": "Small Text",
"hidden": 0,
"hidden": 1,
"in_filter": 0,
"label": "Contact",
"print_hide": 0,
"read_only": 1
},
{
"depends_on": "customer",
"doctype": "DocField",
"fieldname": "contact_mobile",
"fieldtype": "Text",
"hidden": 0,
"hidden": 1,
"label": "Mobile No",
"print_hide": 0,
"read_only": 1
},
{
"depends_on": "customer",
"doctype": "DocField",
"fieldname": "contact_email",
"fieldtype": "Text",
"hidden": 0,
"hidden": 1,
"label": "Contact Email",
"print_hide": 1,
"read_only": 1
@@ -240,6 +237,7 @@
"fieldname": "section_break0",
"fieldtype": "Section Break",
"label": "Price List and Currency",
"options": "icon-globe",
"read_only": 0
},
{
@@ -322,6 +320,7 @@
"fieldtype": "Section Break",
"label": "Items",
"oldfieldtype": "Section Break",
"options": "icon-shopping-cart",
"print_hide": 0,
"read_only": 0,
"search_index": 0
@@ -343,7 +342,6 @@
"doctype": "DocField",
"fieldname": "sec_break23",
"fieldtype": "Section Break",
"options": "Simple",
"read_only": 0
},
{
@@ -419,6 +417,7 @@
"fieldtype": "Section Break",
"label": "Taxes",
"oldfieldtype": "Section Break",
"options": "icon-money",
"read_only": 0
},
{
@@ -518,6 +517,7 @@
"fieldtype": "Section Break",
"label": "Totals",
"oldfieldtype": "Section Break",
"options": "icon-money",
"print_hide": 1,
"read_only": 0
},
@@ -618,6 +618,7 @@
"fieldtype": "Section Break",
"label": "Terms and Conditions",
"oldfieldtype": "Section Break",
"options": "icon-legal",
"print_hide": 0,
"read_only": 0
},
@@ -665,6 +666,7 @@
"fieldname": "contact_section",
"fieldtype": "Section Break",
"label": "Contact Info",
"options": "icon-bullhorn",
"read_only": 0
},
{
@@ -754,6 +756,7 @@
"fieldtype": "Section Break",
"label": "More Info",
"oldfieldtype": "Section Break",
"options": "icon-file-text",
"print_hide": 1,
"read_only": 0
},
@@ -880,8 +883,9 @@
"doctype": "DocField",
"fieldname": "communication_history",
"fieldtype": "Section Break",
"label": "Communication History",
"oldfieldtype": "Section Break",
"options": "Simple",
"options": "icon-comments",
"print_hide": 1,
"read_only": 0
},