[form] added icon in section break

This commit is contained in:
Rushabh Mehta 2013-07-03 10:32:33 +05:30
parent e6bf83e653
commit 78979dca9b
7 changed files with 103 additions and 27 deletions

View File

@ -21,15 +21,16 @@ cur_frm.cscript.onload = function(doc,dt,dn){
}
cur_frm.cscript.refresh = function(doc,dt,dn) {
if(sys_defaults.supp_master_name == 'Supplier Name')
hide_field('naming_series');
else
unhide_field('naming_series');
cur_frm.cscript.setup_dashboard(doc);
if(sys_defaults.supp_master_name == 'Supplier Name')
hide_field('naming_series');
else
unhide_field('naming_series');
if(doc.__islocal){
if(doc.__islocal){
hide_field(['address_html','contact_html']);
}
else{
}
else{
unhide_field(['address_html','contact_html']);
// make lists
cur_frm.cscript.make_address(doc,dt,dn);
@ -43,6 +44,36 @@ 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);
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.layout.add_doctype_badge("Supplier Quotation", "supplier");
cur_frm.layout.add_doctype_badge("Purchase Order", "supplier");
cur_frm.layout.add_doctype_badge("Purchase Receipt", "supplier");
cur_frm.layout.add_doctype_badge("Purchase Invoice", "supplier");
wn.call({
type: "GET",
method:"buying.doctype.supplier.supplier.get_dashboard_info",
args: {
supplier: 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.cscript.make_address = function() {
if(!cur_frm.address_list) {
cur_frm.address_list = new wn.ui.Listing({

View File

@ -193,3 +193,24 @@ class DocType(TransactionBase):
#update master_name in doctype account
webnotes.conn.sql("""update `tabAccount` set master_name = %s,
master_type = 'Supplier' where master_name = %s""" , (new,old))
@webnotes.whitelist()
def get_dashboard_info(supplier):
if not webnotes.has_permission("Supplier", supplier):
webnotes.msgprint("No Permission", raise_exception=True)
out = {}
for doctype in ["Supplier Quotation", "Purchase Order", "Purchase Receipt", "Purchase Invoice"]:
out[doctype] = webnotes.conn.get_value(doctype,
{"supplier": supplier, "docstatus": ["!=", 2] }, "count(*)")
billing = webnotes.conn.sql("""select sum(grand_total), sum(outstanding_amount)
from `tabPurchase Invoice`
where supplier=%s
and docstatus = 1
and fiscal_year = %s""", (supplier, webnotes.conn.get_default("fiscal_year")))
out["total_billing"] = billing[0][0]
out["total_unpaid"] = billing[0][1]
return out

View File

@ -7,6 +7,11 @@ wn.module_page["Buying"] = [
top: true,
icon: "icon-copy",
items: [
{
label: wn._("Supplier"),
description: wn._("Supplier database."),
doctype:"Supplier"
},
{
label: wn._("Material Request"),
description: wn._("Request for purchase."),
@ -28,11 +33,6 @@ wn.module_page["Buying"] = [
title: wn._("Masters"),
icon: "icon-book",
items: [
{
label: wn._("Supplier"),
description: wn._("Supplier database."),
doctype:"Supplier"
},
{
label: wn._("Contact"),
description: wn._("All Contacts."),

View File

@ -32,7 +32,7 @@ cur_frm.add_fetch('lead_name', 'company_name', 'customer_name');
cur_frm.add_fetch('default_sales_partner','commission_rate','default_commission_rate');
cur_frm.cscript.refresh = function(doc,dt,dn) {
cur_frm.layout.clear_dashboard();
cur_frm.cscript.setup_dashboard(doc);
if(sys_defaults.cust_master_name == 'Customer Name')
hide_field('naming_series');
else
@ -41,7 +41,6 @@ cur_frm.cscript.refresh = function(doc,dt,dn) {
if(doc.__islocal){
hide_field(['address_html','contact_html']);
}else{
cur_frm.cscript.setup_dashboard(doc);
unhide_field(['address_html','contact_html']);
// make lists
cur_frm.cscript.make_address(doc,dt,dn);
@ -56,16 +55,18 @@ cur_frm.cscript.refresh = function(doc,dt,dn) {
}
cur_frm.cscript.setup_dashboard = function(doc) {
cur_frm.layout.dashboard.toggle(true);
cur_frm.layout.dashboard.empty().toggle(doc.__islocal ? false : true);
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.layout.add_doctype_badge(wn._("Opportunities"), "Opportunity", "customer");
cur_frm.layout.add_doctype_badge(wn._("Quotations"), "Quotation", "customer");
cur_frm.layout.add_doctype_badge(wn._("Sales Orders"), "Sales Order", "customer");
cur_frm.layout.add_doctype_badge(wn._("Delivery Notes"), "Delivery Note", "customer");
cur_frm.layout.add_doctype_badge(wn._("Sales Invoices"), "Sales Invoice", "customer");
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");
wn.call({
type: "GET",

View File

@ -2,7 +2,7 @@
{
"creation": "2013-06-11 14:26:44",
"docstatus": 0,
"modified": "2013-06-11 14:27:57",
"modified": "2013-07-03 10:26:04",
"modified_by": "Administrator",
"owner": "Administrator"
},
@ -43,6 +43,7 @@
"fieldtype": "Section Break",
"label": "Basic Info",
"oldfieldtype": "Section Break",
"options": "icon-user",
"permlevel": 0,
"reqd": 0
},
@ -142,6 +143,7 @@
"fieldname": "address_contacts",
"fieldtype": "Section Break",
"label": "Address & Contacts",
"options": "icon-map-marker",
"permlevel": 0
},
{
@ -190,6 +192,8 @@
"doctype": "DocField",
"fieldname": "communication_history",
"fieldtype": "Section Break",
"label": "Communication History",
"options": "icon-comments",
"permlevel": 0
},
{
@ -205,6 +209,7 @@
"fieldtype": "Section Break",
"label": "More Info",
"oldfieldtype": "Section Break",
"options": "icon-file-text",
"permlevel": 0
},
{
@ -295,6 +300,7 @@
"fieldtype": "Section Break",
"label": "Sales Team",
"oldfieldtype": "Section Break",
"options": "icon-group",
"permlevel": 0
},
{

View File

@ -2,7 +2,7 @@
{
"creation": "2013-04-10 11:45:37",
"docstatus": 0,
"modified": "2013-06-28 15:08:26",
"modified": "2013-07-03 10:22:31",
"modified_by": "Administrator",
"owner": "Administrator"
},
@ -40,6 +40,13 @@
"doctype": "DocType",
"name": "Lead"
},
{
"doctype": "DocField",
"fieldname": "lead_details",
"fieldtype": "Section Break",
"label": "Lead Details",
"options": "icon-user"
},
{
"description": "To manage multiple series please go to Setup > Manage Series",
"doctype": "DocField",
@ -149,7 +156,9 @@
{
"doctype": "DocField",
"fieldname": "communication_history",
"fieldtype": "Section Break"
"fieldtype": "Section Break",
"label": "Communication History",
"options": "icon-comments"
},
{
"allow_on_submit": 0,
@ -165,7 +174,8 @@
"fieldname": "contact_info",
"fieldtype": "Section Break",
"label": "Address & Contact",
"oldfieldtype": "Column Break"
"oldfieldtype": "Column Break",
"options": "icon-map-marker"
},
{
"depends_on": "eval:doc.__islocal",
@ -248,7 +258,8 @@
"fieldname": "more_info",
"fieldtype": "Section Break",
"label": "More Info",
"oldfieldtype": "Section Break"
"oldfieldtype": "Section Break",
"options": "icon-file-text"
},
{
"doctype": "DocField",

View File

@ -2,7 +2,7 @@
{
"creation": "2013-03-07 18:50:30",
"docstatus": 0,
"modified": "2013-07-02 17:22:21",
"modified": "2013-07-03 10:29:20",
"modified_by": "Administrator",
"owner": "Administrator"
},
@ -47,7 +47,8 @@
"doctype": "DocField",
"fieldname": "from_section",
"fieldtype": "Section Break",
"label": "From"
"label": "From",
"options": "icon-user"
},
{
"description": "To manage multiple series please go to Setup > Manage Series",
@ -144,6 +145,7 @@
"fieldtype": "Section Break",
"label": "Items",
"oldfieldtype": "Section Break",
"options": "icon-shopping-cart",
"read_only": 0
},
{
@ -162,7 +164,9 @@
"doctype": "DocField",
"fieldname": "communication_history",
"fieldtype": "Section Break",
"label": "Communication History",
"oldfieldtype": "Section Break",
"options": "icon-comments",
"read_only": 0
},
{
@ -180,6 +184,7 @@
"fieldname": "contact_info",
"fieldtype": "Section Break",
"label": "Contact Info",
"options": "icon-bullhorn",
"read_only": 0
},
{
@ -284,6 +289,7 @@
"fieldtype": "Section Break",
"label": "More Info",
"oldfieldtype": "Section Break",
"options": "icon-file-text",
"read_only": 0
},
{