mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-03 13:38:27 +00:00
moved directory structure
This commit is contained in:
36
startup/__init__.py
Normal file
36
startup/__init__.py
Normal file
@@ -0,0 +1,36 @@
|
||||
# ERPNext - web based ERP (http://erpnext.com)
|
||||
# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
# default settings that can be made for a profile.
|
||||
from __future__ import unicode_literals
|
||||
|
||||
product_name = "ERPNext"
|
||||
profile_defaults = {
|
||||
"Company": "company",
|
||||
"Territory": "territory"
|
||||
}
|
||||
|
||||
# add startup propertes
|
||||
mail_footer = """<div style="padding: 7px; text-align: right; color: #888"><small>Sent via
|
||||
<a style="color: #888" href="https://erpnext.com">ERPNext</a></div>"""
|
||||
|
||||
def get_monthly_bulk_mail_limit():
|
||||
import webnotes
|
||||
# if global settings, then 500 or unlimited
|
||||
if webnotes.conn.get_value('Email Settings', None, 'outgoing_mail_server'):
|
||||
return 999999
|
||||
else:
|
||||
return 500
|
||||
159
startup/event_handlers.py
Normal file
159
startup/event_handlers.py
Normal file
@@ -0,0 +1,159 @@
|
||||
# ERPNext - web based ERP (http://erpnext.com)
|
||||
# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import webnotes
|
||||
from webnotes.utils import cint
|
||||
import home
|
||||
|
||||
|
||||
def on_login_post_session(login_manager):
|
||||
"""
|
||||
called after login
|
||||
update login_from and delete parallel sessions
|
||||
"""
|
||||
# Clear previous sessions i.e. logout previous log-in attempts
|
||||
exception_list = ['demo@webnotestech.com', 'Administrator', 'Guest']
|
||||
if webnotes.session['user'] not in exception_list:
|
||||
sid_list = webnotes.conn.sql("""
|
||||
DELETE FROM `tabSessions`
|
||||
WHERE
|
||||
user=%s AND
|
||||
sid!=%s""", \
|
||||
(webnotes.session['user'], webnotes.session['sid']), as_list=1)
|
||||
|
||||
# check if account is expired
|
||||
check_if_expired()
|
||||
|
||||
if webnotes.session['user'] not in ('Guest', 'demo@webnotestech.com'):
|
||||
# create feed
|
||||
from webnotes.utils import nowtime
|
||||
from webnotes.profile import get_user_fullname
|
||||
home.make_feed('Login', 'Profile', login_manager.user, login_manager.user,
|
||||
'%s logged in at %s' % (get_user_fullname, nowtime()),
|
||||
login_manager.user=='Administrator' and '#8CA2B3' or '#1B750D')
|
||||
|
||||
|
||||
def comment_added(doc):
|
||||
"""add comment to feed"""
|
||||
home.make_feed('Comment', doc.comment_doctype, doc.comment_docname, doc.comment_by,
|
||||
'<i>"' + doc.comment + '"</i>', '#6B24B3')
|
||||
|
||||
def doclist_all(doc, method):
|
||||
"""doclist trigger called from webnotes.model.doclist on any event"""
|
||||
home.update_feed(doc, method)
|
||||
|
||||
def boot_session(bootinfo):
|
||||
"""boot session - send website info if guest"""
|
||||
import webnotes
|
||||
import webnotes.model.doc
|
||||
|
||||
bootinfo['custom_css'] = webnotes.conn.get_value('Style Settings', None, 'custom_css') or ''
|
||||
bootinfo['website_settings'] = webnotes.model.doc.getsingle('Website Settings')
|
||||
|
||||
if webnotes.session['user']=='Guest':
|
||||
bootinfo['website_menus'] = webnotes.conn.sql("""select label, url, custom_page,
|
||||
parent_label, parentfield
|
||||
from `tabTop Bar Item` where parent='Website Settings' order by idx asc""", as_dict=1)
|
||||
bootinfo['startup_code'] = \
|
||||
webnotes.conn.get_value('Website Settings', None, 'startup_code')
|
||||
else:
|
||||
bootinfo['letter_heads'] = get_letter_heads()
|
||||
|
||||
import webnotes.model.doctype
|
||||
bootinfo['docs'] += webnotes.model.doctype.get('Event')
|
||||
bootinfo['docs'] += webnotes.model.doctype.get('Search Criteria')
|
||||
|
||||
bootinfo['modules_list'] = webnotes.conn.get_global('modules_list')
|
||||
|
||||
# if no company, show a dialog box to create a new company
|
||||
bootinfo['setup_complete'] = webnotes.conn.sql("""select name from
|
||||
tabCompany limit 1""") and 'Yes' or 'No'
|
||||
|
||||
bootinfo['user_background'] = webnotes.conn.get_value("Profile", webnotes.session['user'], 'background_image') or ''
|
||||
|
||||
# load subscription info
|
||||
import conf
|
||||
for key in ['max_users', 'expires_on', 'max_space', 'status', 'developer_mode']:
|
||||
if hasattr(conf, key): bootinfo[key] = getattr(conf, key)
|
||||
|
||||
company = webnotes.conn.sql("select name, default_currency from `tabCompany`", as_dict=1)
|
||||
company_dict = {}
|
||||
for c in company:
|
||||
company_dict.setdefault(c['name'], {}).update(c)
|
||||
|
||||
bootinfo['company'] = company_dict
|
||||
|
||||
def get_letter_heads():
|
||||
"""load letter heads with startup"""
|
||||
import webnotes
|
||||
ret = webnotes.conn.sql("""select name, content from `tabLetter Head`
|
||||
where ifnull(disabled,0)=0""")
|
||||
return dict(ret)
|
||||
|
||||
|
||||
def check_if_expired():
|
||||
"""check if account is expired. If expired, do not allow login"""
|
||||
import conf
|
||||
# check if expires_on is specified
|
||||
if not hasattr(conf, 'expires_on'): return
|
||||
|
||||
# check if expired
|
||||
from datetime import datetime, date
|
||||
expires_on = datetime.strptime(conf.expires_on, '%Y-%m-%d').date()
|
||||
if date.today() <= expires_on: return
|
||||
|
||||
# if expired, stop user from logging in
|
||||
from webnotes.utils import formatdate
|
||||
if 'System Manager' in webnotes.user.roles:
|
||||
webnotes.response['server_messages'] = """Oops! \
|
||||
Your subscription expired on <b>%s</b>.
|
||||
|
||||
Nothing catastrophic.
|
||||
|
||||
Just drop in a mail at <b>support@erpnext.com</b> and \
|
||||
we will guide you to get your account re-activated.""" % formatdate(conf.expires_on)
|
||||
else:
|
||||
webnotes.response['server_messages'] = """Oops! \
|
||||
Your subscription expired on <b>%s</b>.
|
||||
|
||||
Nothing catastrophic.
|
||||
|
||||
Just ask your System Manager to drop in a mail at <b>support@erpnext.com</b> and \
|
||||
we will guide him to get your account re-activated.""" % formatdate(conf.expires_on)
|
||||
|
||||
webnotes.response['message'] = 'Account Expired'
|
||||
raise webnotes.AuthenticationError
|
||||
|
||||
#### website
|
||||
|
||||
def get_web_script():
|
||||
"""returns web startup script"""
|
||||
return webnotes.conn.get_value('Website Settings', None, 'startup_code') or ''
|
||||
|
||||
def get_web_style():
|
||||
"""returns web css"""
|
||||
return webnotes.conn.get_value('Style Settings', None, 'custom_css') or ''
|
||||
|
||||
def get_web_header(page_name):
|
||||
"""get website header"""
|
||||
from website.utils import get_header
|
||||
return get_header(page_name)
|
||||
|
||||
def get_web_footer(page_name):
|
||||
"""get website footer"""
|
||||
from website.utils import get_footer
|
||||
return get_footer(page_name)
|
||||
205
startup/js/feature_setup.js
Normal file
205
startup/js/feature_setup.js
Normal file
@@ -0,0 +1,205 @@
|
||||
// ERPNext - web based ERP (http://erpnext.com)
|
||||
// Copyright (C) 2012 Web Notes Technologies Pvt Ltd
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/* features setup "Dictionary", "Script"
|
||||
Dictionary Format
|
||||
'projects': {
|
||||
'Sales Order': {
|
||||
'fields':['project_name'],
|
||||
'sales_order_details':['projected_qty']
|
||||
},
|
||||
'Purchase Order': {
|
||||
'fields':['project_name']
|
||||
}
|
||||
}
|
||||
// ====================================================================*/
|
||||
pscript.feature_dict = {
|
||||
'fs_projects': {
|
||||
'BOM': {'fields':['project_name']},
|
||||
'Delivery Note': {'fields':['project_name']},
|
||||
'Purchase Invoice': {'entries':['project_name']},
|
||||
'Production Order': {'fields':['project_name']},
|
||||
'Purchase Order': {'po_details':['project_name']},
|
||||
'Purchase Receipt': {'purchase_receipt_details':['project_name']},
|
||||
'Sales Invoice': {'fields':['project_name']},
|
||||
'Sales Order': {'fields':['project_name']},
|
||||
'Stock Entry': {'fields':['project_name']},
|
||||
'Timesheet': {'timesheet_details':['project_name']}
|
||||
},
|
||||
'fs_packing_details': {
|
||||
//'Delivery Note': {'fields':['packing_details','print_packing_slip','packing_checked_by','packed_by','pack_size','shipping_mark'],'delivery_note_details':['no_of_packs','pack_gross_wt','pack_nett_wt','pack_no','pack_unit']},
|
||||
//'Sales Order': {'fields':['packing_details']}
|
||||
},
|
||||
'fs_discounts': {
|
||||
'Delivery Note': {'delivery_note_details':['adj_rate']},
|
||||
'Quotation': {'quotation_details':['adj_rate']},
|
||||
'Sales Invoice': {'entries':['adj_rate']},
|
||||
'Sales Order': {'sales_order_details':['adj_rate','ref_rate']}
|
||||
},
|
||||
'fs_purchase_discounts': {
|
||||
'Purchase Order': {'po_details':['purchase_ref_rate', 'discount_rate', 'import_ref_rate']},
|
||||
'Purchase Receipt': {'purchase_receipt_details':['purchase_ref_rate', 'discount_rate', 'import_ref_rate']},
|
||||
'Purchase Invoice': {'entries':['purchase_ref_rate', 'discount_rate', 'import_ref_rate']}
|
||||
},
|
||||
'fs_brands': {
|
||||
'Delivery Note': {'delivery_note_details':['brand']},
|
||||
'Purchase Request': {'indent_details':['brand']},
|
||||
'Item': {'fields':['brand']},
|
||||
'Purchase Order': {'po_details':['brand']},
|
||||
'Purchase Invoice': {'entries':['brand']},
|
||||
'Quotation': {'quotation_details':['brand']},
|
||||
'Sales Invoice': {'entries':['brand']},
|
||||
'Sales BOM': {'fields':['new_item_brand']},
|
||||
'Sales Order': {'sales_order_details':['brand']},
|
||||
'Serial No': {'fields':['brand']}
|
||||
},
|
||||
'fs_after_sales_installations': {
|
||||
'Delivery Note': {'fields':['installation_status','per_installed'],'delivery_note_details':['installed_qty']}
|
||||
},
|
||||
'fs_item_batch_nos': {
|
||||
'Delivery Note': {'delivery_note_details':['batch_no']},
|
||||
'Item': {'fields':['has_batch_no']},
|
||||
'Purchase Receipt': {'purchase_receipt_details':['batch_no']},
|
||||
'Quality Inspection': {'fields':['batch_no']},
|
||||
'Sales and Pruchase Return Wizard': {'return_details':['batch_no']},
|
||||
'Sales Invoice': {'entries':['batch_no']},
|
||||
'Stock Entry': {'mtn_details':['batch_no']},
|
||||
'Stock Ledger Entry': {'fields':['batch_no']}
|
||||
},
|
||||
'fs_item_serial_nos': {
|
||||
'Customer Issue': {'fields':['serial_no']},
|
||||
'Delivery Note': {'delivery_note_details':['serial_no'],'packing_details':['serial_no']},
|
||||
'Installation Note': {'installed_item_details':['serial_no']},
|
||||
'Item': {'fields':['has_serial_no']},
|
||||
'Maintenance Schedule': {'item_maintenance_detail':['serial_no'],'maintenance_schedule_detail':['serial_no']},
|
||||
'Maintenance Visit': {'maintenance_visit_details':['serial_no']},
|
||||
'Purchase Receipt': {'purchase_receipt_details':['serial_no']},
|
||||
'Quality Inspection': {'fields':['item_serial_no']},
|
||||
'Sales and Pruchase Return Wizard': {'return_details':['serial_no']},
|
||||
'Sales Invoice': {'entries':['serial_no']},
|
||||
'Stock Entry': {'mtn_details':['serial_no']},
|
||||
'Stock Ledger Entry': {'fields':['serial_no']}
|
||||
},
|
||||
'fs_item_barcode': {
|
||||
'Item': {'fields': ['barcode']},
|
||||
'Delivery Note': {'delivery_note_details': ['barcode']},
|
||||
'Sales Invoice': {'entries': ['barcode']}
|
||||
},
|
||||
'fs_item_group_in_details': {
|
||||
'Delivery Note': {'delivery_note_details':['item_group']},
|
||||
'Opportunity': {'enquiry_details':['item_group']},
|
||||
'Purchase Request': {'indent_details':['item_group']},
|
||||
'Item': {'fields':['item_group']},
|
||||
'Global Defaults': {'fields':['default_item_group']},
|
||||
'Purchase Order': {'po_details':['item_group']},
|
||||
'Purchase Receipt': {'purchase_receipt_details':['item_group']},
|
||||
'Purchase Voucher': {'entries':['item_group']},
|
||||
'Quotation': {'quotation_details':['item_group']},
|
||||
'Sales Invoice': {'entries':['item_group']},
|
||||
'Sales BOM': {'fields':['serial_no']},
|
||||
'Sales Order': {'sales_order_details':['item_group']},
|
||||
'Serial No': {'fields':['item_group']},
|
||||
'Sales Partner': {'partner_target_details':['item_group']},
|
||||
'Sales Person': {'target_details':['item_group']},
|
||||
'Territory': {'target_details':['item_group']}
|
||||
},
|
||||
'fs_page_break': {
|
||||
'Delivery Note': {'delivery_note_details':['page_break'],'packing_details':['page_break']},
|
||||
'Purchase Request': {'indent_details':['page_break']},
|
||||
'Purchase Order': {'po_details':['page_break']},
|
||||
'Purchase Receipt': {'purchase_receipt_details':['page_break']},
|
||||
'Purchase Voucher': {'entries':['page_break']},
|
||||
'Quotation': {'quotation_details':['page_break']},
|
||||
'Sales Invoice': {'entries':['page_break']},
|
||||
'Sales Order': {'sales_order_details':['page_break']}
|
||||
},
|
||||
'fs_exports': {
|
||||
'Delivery Note': {'fields':['Note','conversion_rate','currency','grand_total_export','in_words_export','rounded_total_export'],'delivery_note_details':['base_ref_rate','amount','basic_rate']},
|
||||
'POS Setting': {'fields':['conversion_rate','currency']},
|
||||
'Quotation': {'fields':['Note HTML','OT Notes','conversion_rate','currency','grand_total_export','in_words_export','rounded_total_export'],'quotation_details':['base_ref_rate','amount','basic_rate']},
|
||||
'Sales Invoice': {'fields':['conversion_rate','currency','grand_total_export','in_words_export','rounded_total_export'],'entries':['base_ref_rate','amount','basic_rate']},
|
||||
'Item': {'ref_rate_details':['ref_currency']},
|
||||
'Sales BOM': {'fields':['currency']},
|
||||
'Sales Order': {'fields':['Note1','OT Notes','conversion_rate','currency','grand_total_export','in_words_export','rounded_total_export'],'sales_order_details':['base_ref_rate','amount','basic_rate']}
|
||||
},
|
||||
'fs_imports': {
|
||||
'Purchase Invoice': {'fields':['conversion_rate','currency','grand_total_import','in_words_import','net_total_import','other_charges_added_import','other_charges_deducted_import'],'entries':['purchase_ref_rate', 'amount','rate']},
|
||||
'Purchase Order': {'fields':['Note HTML','conversion_rate','currency','grand_total_import','in_words_import','net_total_import','other_charges_added_import','other_charges_deducted_import'],'po_details':['purchase_ref_rate', 'amount','purchase_rate']},
|
||||
'Purchase Receipt': {'fields':['conversion_rate','currency','grand_total_import','in_words_import','net_total_import','other_charges_added_import','other_charges_deducted_import'],'purchase_receipt_details':['purchase_ref_rate','amount','purchase_rate']},
|
||||
'Supplier Quotation': {'fields':['conversion_rate','currency']}
|
||||
},
|
||||
'fs_item_advanced': {
|
||||
'Item': {'fields':['item_customer_details']}
|
||||
},
|
||||
'fs_sales_extras': {
|
||||
'Address': {'fields':['sales_partner']},
|
||||
'Contact': {'fields':['sales_partner']},
|
||||
'Customer': {'fields':['sales_team']},
|
||||
'Delivery Note': {'fields':['sales_team','Packing List']},
|
||||
'Item': {'fields':['item_customer_details']},
|
||||
'Sales Invoice': {'fields':['sales_team']},
|
||||
'Sales Order': {'fields':['sales_team','Packing List']}
|
||||
},
|
||||
'fs_more_info': {
|
||||
'Delivery Note': {'fields':['More Info']},
|
||||
'Opportunity': {'fields':['More Info']},
|
||||
'Purchase Request': {'fields':['More Info']},
|
||||
'Lead': {'fields':['More Info']},
|
||||
'Purchase Invoice': {'fields':['More Info']},
|
||||
'Purchase Order': {'fields':['More Info']},
|
||||
'Purchase Receipt': {'fields':['More Info']},
|
||||
'Quotation': {'fields':['More Info']},
|
||||
'Sales Invoice': {'fields':['More Info']},
|
||||
'Sales Order': {'fields':['More Info']},
|
||||
},
|
||||
'fs_quality': {
|
||||
'Item': {'fields':['Item Inspection Criteria','inspection_required']},
|
||||
'Purchase Receipt': {'purchase_receipt_details':['qa_no']}
|
||||
},
|
||||
'fs_manufacturing': {
|
||||
'Item': {'fields':['Manufacturing']}
|
||||
},
|
||||
'fs_pos': {
|
||||
'Sales Invoice': {'fields':['is_pos']}
|
||||
},
|
||||
'fs_recurring_invoice': {
|
||||
'Sales Invoice': {'fields': ['Recurring Invoice']}
|
||||
}
|
||||
}
|
||||
|
||||
$(document).bind('form_refresh', function() {
|
||||
for(sys_feat in sys_defaults)
|
||||
{
|
||||
if(sys_defaults[sys_feat]=='0' && (sys_feat in pscript.feature_dict)) //"Features to hide" exists
|
||||
{
|
||||
if(cur_frm.doc.doctype in pscript.feature_dict[sys_feat])
|
||||
{
|
||||
for(fort in pscript.feature_dict[sys_feat][cur_frm.doc.doctype])
|
||||
{
|
||||
if(fort=='fields')
|
||||
hide_field(pscript.feature_dict[sys_feat][cur_frm.doc.doctype][fort]);
|
||||
else if(cur_frm.fields_dict[fort])
|
||||
{
|
||||
for(grid_field in pscript.feature_dict[sys_feat][cur_frm.doc.doctype][fort])
|
||||
cur_frm.fields_dict[fort].grid.set_column_disp(pscript.feature_dict[sys_feat][cur_frm.doc.doctype][fort][grid_field], false);
|
||||
}
|
||||
else
|
||||
msgprint('Grid "'+fort+'" does not exists');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
118
startup/js/modules.js
Normal file
118
startup/js/modules.js
Normal file
@@ -0,0 +1,118 @@
|
||||
// ERPNext - web based ERP (http://erpnext.com)
|
||||
// Copyright (C) 2012 Web Notes Technologies Pvt Ltd
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
wn.provide('erpnext.module_page');
|
||||
|
||||
erpnext.module_page.setup_page = function(module, wrapper) {
|
||||
erpnext.module_page.hide_links(wrapper);
|
||||
erpnext.module_page.make_list(module, wrapper);
|
||||
$(wrapper).find("a[title]").tooltip({
|
||||
delay: { show: 500, hide: 100 }
|
||||
});
|
||||
}
|
||||
|
||||
// hide list links where the user does
|
||||
// not have read permissions
|
||||
|
||||
erpnext.module_page.hide_links = function(wrapper) {
|
||||
// lists
|
||||
$(wrapper).find('[href*="List/"]').each(function() {
|
||||
var href = $(this).attr('href');
|
||||
var dt = href.split('/')[1];
|
||||
if(wn.boot.profile.all_read.indexOf(get_label_doctype(dt))==-1) {
|
||||
var txt = $(this).text();
|
||||
$(this).parent().css('color', '#999').html(txt);
|
||||
}
|
||||
});
|
||||
|
||||
// reports
|
||||
$(wrapper).find('[data-doctype]').each(function() {
|
||||
var dt = $(this).attr('data-doctype');
|
||||
if(wn.boot.profile.all_read.indexOf(dt)==-1) {
|
||||
var txt = $(this).text();
|
||||
$(this).parent().css('color', '#999').html(txt);
|
||||
}
|
||||
});
|
||||
|
||||
// single (forms)
|
||||
$(wrapper).find('[href*="Form/"]').each(function() {
|
||||
var href = $(this).attr('href');
|
||||
var dt = href.split('/')[1];
|
||||
if(wn.boot.profile.all_read.indexOf(get_label_doctype(dt))==-1) {
|
||||
var txt = $(this).text();
|
||||
$(this).parent().css('color', '#999').html(txt);
|
||||
}
|
||||
});
|
||||
|
||||
// pages
|
||||
$(wrapper).find('[data-role]').each(function() {
|
||||
if(!has_common(user_roles, [$(this).attr("data-role"), "System Manager"])) {
|
||||
var html = $(this).html();
|
||||
$(this).parent().css('color', '#999');
|
||||
$(this).replaceWith(html);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// make list of reports
|
||||
|
||||
erpnext.module_page.make_list = function(module, wrapper) {
|
||||
// make project listing
|
||||
var $w = $(wrapper).find('.reports-list');
|
||||
var $parent1 = $('<div style="width: 45%; float: left; margin-right: 4.5%"></div>').appendTo($w);
|
||||
var $parent2 = $('<div style="width: 45%; float: left;"></div>').appendTo($w);
|
||||
|
||||
wrapper.list1 = new wn.ui.Listing({
|
||||
parent: $parent1,
|
||||
method: 'utilities.get_sc_list',
|
||||
render_row: function(row, data) {
|
||||
if(!data.parent_doc_type) data.parent_doc_type = data.doc_type;
|
||||
$(row).html(repl('<a href="#!Report/%(doc_type)s/%(criteria_name)s" \
|
||||
data-doctype="%(parent_doc_type)s">\
|
||||
%(criteria_name)s</a>', data))
|
||||
},
|
||||
args: { module: module },
|
||||
no_refresh: true,
|
||||
callback: function(r) {
|
||||
erpnext.module_page.hide_links($parent1)
|
||||
}
|
||||
});
|
||||
wrapper.list1.run();
|
||||
|
||||
wrapper.list2 = new wn.ui.Listing({
|
||||
parent: $parent2,
|
||||
method: 'utilities.get_report_list',
|
||||
render_row: function(row, data) {
|
||||
$(row).html(repl('<a href="#!Report2/%(ref_doctype)s/%(name)s" \
|
||||
data-doctype="%(ref_doctype)s">\
|
||||
%(name)s</a>', data))
|
||||
},
|
||||
args: { module: module },
|
||||
no_refresh: true,
|
||||
callback: function(r) {
|
||||
erpnext.module_page.hide_links($parent2)
|
||||
}
|
||||
});
|
||||
wrapper.list2.run();
|
||||
|
||||
// show link to all reports
|
||||
$parent1.find('.list-toolbar-wrapper')
|
||||
.prepend("<div class=\"show-all-reports\">\
|
||||
<a href=\"#List/Search Criteria\"> [ List Of All Reports ]</a></div>");
|
||||
$parent2.find('.list-toolbar-wrapper')
|
||||
.prepend("<div class=\"show-all-reports\">\
|
||||
<a href=\"#List/Report\"> [ List Of All Reports (New) ]</a></div>");
|
||||
}
|
||||
109
startup/js/toolbar.js
Normal file
109
startup/js/toolbar.js
Normal file
@@ -0,0 +1,109 @@
|
||||
// ERPNext - web based ERP (http://erpnext.com)
|
||||
// Copyright (C) 2012 Web Notes Technologies Pvt Ltd
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/* toolbar settings */
|
||||
wn.provide('erpnext.toolbar');
|
||||
|
||||
erpnext.toolbar.setup = function() {
|
||||
// modules
|
||||
erpnext.toolbar.add_modules();
|
||||
|
||||
// profile
|
||||
$('#toolbar-user').append('<li><a href="#!profile-settings">Profile Settings</a></li>');
|
||||
|
||||
$('.navbar .pull-right').append('\
|
||||
<li><a href="#!messages" title="Unread Messages"><span class="navbar-new-comments"></span></a></li>');
|
||||
|
||||
// help
|
||||
$('.navbar .pull-right').prepend('<li class="dropdown">\
|
||||
<a class="dropdown-toggle" data-toggle="dropdown" href="#" \
|
||||
onclick="return false;">Help<b class="caret"></b></a>\
|
||||
<ul class="dropdown-menu" id="toolbar-help">\
|
||||
</ul></li>')
|
||||
|
||||
$('#toolbar-help').append('<li><a href="https://erpnext.com/manual" target="_blank">\
|
||||
Documentation</a></li>')
|
||||
|
||||
$('#toolbar-help').append('<li><a href="http://groups.google.com/group/erpnext-user-forum" target="_blank">\
|
||||
Forum</a></li>')
|
||||
|
||||
$('#toolbar-help').append('<li><a href="http://www.providesupport.com?messenger=iwebnotes" target="_blank">\
|
||||
Live Chat (Office Hours)</a></li>')
|
||||
|
||||
erpnext.toolbar.set_new_comments();
|
||||
}
|
||||
|
||||
erpnext.toolbar.add_modules = function() {
|
||||
$('<li class="dropdown">\
|
||||
<a class="dropdown-toggle" data-toggle="dropdown" href="#"\
|
||||
onclick="return false;">Modules<b class="caret"></b></a>\
|
||||
<ul class="dropdown-menu modules">\
|
||||
</ul>\
|
||||
</li>').prependTo('.navbar .nav:first');
|
||||
|
||||
// if no modules list then show all
|
||||
if(wn.boot.modules_list && typeof(wn.boot.modules_list) == 'string') {
|
||||
wn.boot.modules_list = JSON.parse(wn.boot.modules_list);
|
||||
}
|
||||
else
|
||||
wn.boot.modules_list = keys(erpnext.modules).sort();
|
||||
|
||||
// add to dropdown
|
||||
for(var i in wn.boot.modules_list) {
|
||||
var m = wn.boot.modules_list[i]
|
||||
|
||||
if(m!='Setup' && wn.boot.profile.allow_modules.indexOf(m)!=-1) {
|
||||
args = {
|
||||
module: m,
|
||||
module_page: erpnext.modules[m],
|
||||
module_label: m=='HR' ? 'Human Resources' : m
|
||||
}
|
||||
|
||||
$('.navbar .modules').append(repl('<li><a href="#!%(module_page)s" \
|
||||
data-module="%(module)s">%(module_label)s</a></li>', args));
|
||||
}
|
||||
}
|
||||
|
||||
// dasboard for accounts system manager
|
||||
if(user_roles.indexOf("Accounts Manager")!=-1) {
|
||||
$('.navbar .modules').append('<li><a href="#!dashboard" \
|
||||
data-module="Dashboard">Dashboard</a></li>');
|
||||
}
|
||||
|
||||
// setup for system manager
|
||||
if(user_roles.indexOf("System Manager")!=-1) {
|
||||
$('.navbar .modules').append('<li class="divider"></li>\
|
||||
<li><a href="#!Setup" data-module="Setup">Setup</a></li>');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
erpnext.toolbar.set_new_comments = function(new_comments) {
|
||||
var navbar_nc = $('.navbar-new-comments');
|
||||
if(new_comments && new_comments.length>0) {
|
||||
navbar_nc.text(new_comments.length);
|
||||
navbar_nc.addClass('navbar-new-comments-true')
|
||||
$.each(new_comments, function(i, v) {
|
||||
var msg = 'New Message: ' + (v[1].length<=100 ? v[1] : (v[1].substr(0, 100) + "..."));
|
||||
var id = v[0].replace('/', '-');
|
||||
if(!$('#' + id)[0]) { show_alert(msg, id); }
|
||||
})
|
||||
} else {
|
||||
navbar_nc.removeClass('navbar-new-comments-true');
|
||||
navbar_nc.text(0);
|
||||
}
|
||||
}
|
||||
|
||||
150
startup/report_data_map.py
Normal file
150
startup/report_data_map.py
Normal file
@@ -0,0 +1,150 @@
|
||||
# ERPNext - web based ERP (http://erpnext.com)
|
||||
# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from __future__ import unicode_literals
|
||||
|
||||
# mappings for table dumps
|
||||
# "remember to add indexes!"
|
||||
|
||||
data_map = {
|
||||
"Company": {
|
||||
"columns": ["name"],
|
||||
"conditions": ["docstatus < 2"]
|
||||
},
|
||||
"Fiscal Year": {
|
||||
"columns": ["name", "year_start_date",
|
||||
"adddate(adddate(year_start_date, interval 1 year), interval -1 day) as year_end_date"]
|
||||
},
|
||||
|
||||
# Accounts
|
||||
"Account": {
|
||||
"columns": ["name", "parent_account", "lft", "rgt", "debit_or_credit", "is_pl_account",
|
||||
"company"],
|
||||
"order_by": "lft"
|
||||
},
|
||||
"Cost Center": {
|
||||
"columns": ["name", "lft", "rgt"],
|
||||
"order_by": "lft"
|
||||
},
|
||||
"GL Entry": {
|
||||
"columns": ["account", "posting_date", "cost_center", "debit", "credit", "is_opening",
|
||||
"company", "voucher_type", "voucher_no", "remarks"],
|
||||
"conditions": ["ifnull(is_cancelled, 'No')='No'"],
|
||||
"order_by": "posting_date, account",
|
||||
"links": {
|
||||
"account": ["Account", "name"],
|
||||
"company": ["Company", "name"],
|
||||
"cost_center": ["Cost Center", "name"]
|
||||
}
|
||||
},
|
||||
|
||||
# Stock
|
||||
"Item": {
|
||||
"columns": ["name", "if(item_name=name, '', item_name) as item_name",
|
||||
"item_group as parent_item_group", "stock_uom", "brand", "valuation_method"],
|
||||
"order_by": "name",
|
||||
"links": {
|
||||
"parent_item_group": ["Item Group", "name"],
|
||||
}
|
||||
},
|
||||
"Item Group": {
|
||||
"columns": ["name", "parent_item_group"],
|
||||
"order_by": "lft"
|
||||
},
|
||||
"Warehouse": {
|
||||
"columns": ["name"],
|
||||
"order_by": "name"
|
||||
},
|
||||
"Stock Ledger Entry": {
|
||||
"columns": ["posting_date", "posting_time", "item_code", "warehouse", "actual_qty as qty",
|
||||
"voucher_type", "voucher_no", "ifnull(incoming_rate,0) as incoming_rate"],
|
||||
"conditions": ["ifnull(is_cancelled, 'No')='No'"],
|
||||
"order_by": "posting_date, posting_time, name",
|
||||
"links": {
|
||||
"item_code": ["Item", "name"],
|
||||
"warehouse": ["Warehouse", "name"]
|
||||
},
|
||||
"force_index": "posting_sort_index"
|
||||
},
|
||||
|
||||
# Sales
|
||||
"Customer": {
|
||||
"columns": ["name", "if(customer_name=name, '', customer_name) as customer_name",
|
||||
"customer_group as parent_customer_group", "territory as parent_territory"],
|
||||
"order_by": "name",
|
||||
"links": {
|
||||
"parent_customer_group": ["Customer Group", "name"],
|
||||
"parent_territory": ["Territory", "name"],
|
||||
}
|
||||
},
|
||||
"Customer Group": {
|
||||
"columns": ["name", "parent_customer_group"],
|
||||
"order_by": "lft"
|
||||
},
|
||||
"Territory": {
|
||||
"columns": ["name", "parent_territory"],
|
||||
"order_by": "lft"
|
||||
},
|
||||
"Sales Invoice": {
|
||||
"columns": ["name", "customer", "posting_date", "company"],
|
||||
"conditions": ["docstatus=1"],
|
||||
"order_by": "posting_date",
|
||||
"links": {
|
||||
"customer": ["Customer", "name"],
|
||||
"company":["Company", "name"]
|
||||
}
|
||||
},
|
||||
"Sales Invoice Item": {
|
||||
"columns": ["parent", "item_code", "qty", "amount"],
|
||||
"conditions": ["docstatus=1", "ifnull(parent, '')!=''"],
|
||||
"order_by": "parent",
|
||||
"links": {
|
||||
"parent": ["Sales Invoice", "name"],
|
||||
"item_code": ["Item", "name"]
|
||||
}
|
||||
},
|
||||
"Supplier": {
|
||||
"columns": ["name", "if(supplier_name=name, '', supplier_name) as supplier_name",
|
||||
"supplier_type as parent_supplier_type"],
|
||||
"order_by": "name",
|
||||
"links": {
|
||||
"parent_supplier_type": ["Supplier Type", "name"],
|
||||
}
|
||||
},
|
||||
"Supplier Type": {
|
||||
"columns": ["name"],
|
||||
"order_by": "name"
|
||||
},
|
||||
"Purchase Invoice": {
|
||||
"columns": ["name", "supplier", "posting_date", "company"],
|
||||
"conditions": ["docstatus=1"],
|
||||
"order_by": "posting_date",
|
||||
"links": {
|
||||
"supplier": ["Supplier", "name"],
|
||||
"company":["Company", "name"]
|
||||
}
|
||||
},
|
||||
"Purchase Invoice Item": {
|
||||
"columns": ["parent", "item_code", "qty", "amount"],
|
||||
"conditions": ["docstatus=1", "ifnull(parent, '')!=''"],
|
||||
"order_by": "parent",
|
||||
"links": {
|
||||
"parent": ["Purchase Invoice", "name"],
|
||||
"item_code": ["Item", "name"]
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
62
startup/schedule_handlers.py
Normal file
62
startup/schedule_handlers.py
Normal file
@@ -0,0 +1,62 @@
|
||||
# ERPNext - web based ERP (http://erpnext.com)
|
||||
# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from __future__ import unicode_literals
|
||||
"""will be called by scheduler"""
|
||||
|
||||
import webnotes
|
||||
from webnotes.utils import scheduler
|
||||
|
||||
def execute_all():
|
||||
"""
|
||||
* get support email
|
||||
* recurring invoice
|
||||
"""
|
||||
# pull emails
|
||||
from support.doctype.support_ticket import get_support_mails
|
||||
run_fn(get_support_mails)
|
||||
|
||||
# bulk email
|
||||
from webnotes.utils.email_lib.bulk import flush
|
||||
run_fn(flush)
|
||||
|
||||
def execute_daily():
|
||||
# email digest
|
||||
from setup.doctype.email_digest.email_digest import send
|
||||
run_fn(send)
|
||||
|
||||
# run recurring invoices
|
||||
from accounts.doctype.gl_control.gl_control import manage_recurring_invoices
|
||||
run_fn(manage_recurring_invoices)
|
||||
|
||||
# send bulk emails
|
||||
from webnotes.utils.email_lib.bulk import clear_outbox
|
||||
run_fn(clear_outbox)
|
||||
|
||||
def execute_weekly():
|
||||
pass
|
||||
|
||||
def execute_monthly():
|
||||
pass
|
||||
|
||||
def execute_hourly():
|
||||
pass
|
||||
|
||||
def run_fn(fn):
|
||||
try:
|
||||
fn()
|
||||
except Exception, e:
|
||||
scheduler.log(fn.func_name)
|
||||
64
startup/startup.css
Normal file
64
startup/startup.css
Normal file
@@ -0,0 +1,64 @@
|
||||
h1, h2, h3, h4, h5 {
|
||||
font-family: Arial, Helvetica, sans-serif;
|
||||
margin-top: 0.2em;
|
||||
}
|
||||
|
||||
body {
|
||||
font-family: Arial, Helvetica, sans-serif;
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
span, div, td, input, textarea, button, select {
|
||||
font-family: inherit;
|
||||
}
|
||||
|
||||
.small {
|
||||
font-size: 11.5px;
|
||||
}
|
||||
|
||||
.erpnext-footer {
|
||||
margin: 11px auto;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.navbar-new-comments {
|
||||
margin: -3px 0px;
|
||||
padding: 2px;
|
||||
min-width: 20px;
|
||||
text-align: center;
|
||||
display: inline-block;
|
||||
border-radius: 2px;
|
||||
color: #999999;
|
||||
background-color: #333131;
|
||||
}
|
||||
|
||||
.navbar-new-comments:hover,
|
||||
.navbar-new-comments:active,
|
||||
.navbar-new-comments:focus {
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.navbar-new-comments-true {
|
||||
color: #fff;
|
||||
background-color: #B00D07;
|
||||
}
|
||||
|
||||
/*extra size menus for recent*/
|
||||
.dropdown-menu#toolbar-recent, .dropdown-menu#toolbar-options, .dropdown-menu#toolbar-help{
|
||||
min-width: 160px !important;
|
||||
max-width: 260px !important;
|
||||
}
|
||||
|
||||
.expiry-info {
|
||||
margin-top: 40px;
|
||||
margin-bottom: -40px;
|
||||
text-align: center;
|
||||
background-color: rgb(255, 255, 204);
|
||||
padding: 7px;
|
||||
z-index: 1;
|
||||
}
|
||||
|
||||
.show-all-reports {
|
||||
margin-top: 5px;
|
||||
font-size: 11px;
|
||||
}
|
||||
197
startup/startup.js
Normal file
197
startup/startup.js
Normal file
@@ -0,0 +1,197 @@
|
||||
// ERPNext - web based ERP (http://erpnext.com)
|
||||
// Copyright (C) 2012 Web Notes Technologies Pvt Ltd
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
var current_module;
|
||||
var is_system_manager = 0;
|
||||
|
||||
wn.provide('erpnext.startup');
|
||||
|
||||
erpnext.modules = {
|
||||
'Selling': 'selling-home',
|
||||
'Accounts': 'accounts-home',
|
||||
'Stock': 'stock-home',
|
||||
'Buying': 'buying-home',
|
||||
'Support': 'support-home',
|
||||
'Projects': 'projects-home',
|
||||
'Production': 'production-home',
|
||||
'Website': 'website-home',
|
||||
'HR': 'hr-home',
|
||||
'Setup': 'Setup',
|
||||
'Activity': 'activity',
|
||||
'To Do': 'todo',
|
||||
'Calendar': 'calendar',
|
||||
'Messages': 'messages',
|
||||
'Knowledge Base': 'questions',
|
||||
'Dashboard': 'dashboard'
|
||||
}
|
||||
|
||||
// wn.modules is used in breadcrumbs for getting module home page
|
||||
wn.provide('wn.modules');
|
||||
$.extend(wn.modules, erpnext.modules);
|
||||
wn.modules['Core'] = 'Setup';
|
||||
|
||||
erpnext.startup.set_globals = function() {
|
||||
if(inList(user_roles,'System Manager')) is_system_manager = 1;
|
||||
}
|
||||
|
||||
erpnext.startup.start = function() {
|
||||
console.log('Starting up...');
|
||||
$('#startup_div').html('Starting up...').toggle(true);
|
||||
|
||||
|
||||
erpnext.startup.set_globals();
|
||||
|
||||
if(user != 'Guest'){
|
||||
if(wn.boot.user_background) {
|
||||
erpnext.set_user_background(wn.boot.user_background);
|
||||
}
|
||||
|
||||
// always allow apps
|
||||
wn.boot.profile.allow_modules = wn.boot.profile.allow_modules.concat(
|
||||
['To Do', 'Knowledge Base', 'Calendar', 'Activity', 'Messages'])
|
||||
|
||||
// setup toolbar
|
||||
erpnext.toolbar.setup();
|
||||
|
||||
// set interval for updates
|
||||
erpnext.startup.set_periodic_updates();
|
||||
|
||||
// border to the body
|
||||
// ------------------
|
||||
$('footer').html('<div class="web-footer erpnext-footer">\
|
||||
<a href="#!attributions">ERPNext | Attributions and License</a></div>');
|
||||
|
||||
// complete registration
|
||||
if(in_list(user_roles,'System Manager') && (wn.boot.setup_complete=='No')) {
|
||||
wn.require("app/js/complete_setup.js");
|
||||
erpnext.complete_setup.show();
|
||||
}
|
||||
if(wn.boot.expires_on && in_list(user_roles, 'System Manager')) {
|
||||
var today = dateutil.str_to_obj(dateutil.get_today());
|
||||
var expires_on = dateutil.str_to_obj(wn.boot.expires_on);
|
||||
var diff = dateutil.get_diff(expires_on, today);
|
||||
if (0 <= diff && diff <= 15) {
|
||||
var expiry_string = diff==0 ? "today" : repl("in %(diff)s day(s)", { diff: diff });
|
||||
$('header').append(repl('<div class="expiry-info"> \
|
||||
Your ERPNext subscription will <b>expire %(expiry_string)s</b>. \
|
||||
Please renew your subscription to continue using ERPNext \
|
||||
(and remove this annoying banner). \
|
||||
</div>', { expiry_string: expiry_string }));
|
||||
} else if (diff < 0) {
|
||||
$('header').append(repl('<div class="expiry-info"> \
|
||||
This ERPNext subscription <b>has expired</b>. \
|
||||
</div>', { expiry_string: expiry_string }));
|
||||
}
|
||||
}
|
||||
erpnext.set_about();
|
||||
if(wn.control_panel.custom_startup_code)
|
||||
eval(wn.control_panel.custom_startup_code);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ========== Update Messages ============
|
||||
erpnext.update_messages = function(reset) {
|
||||
// Updates Team Messages
|
||||
|
||||
if(inList(['Guest'], user) || !wn.session_alive) { return; }
|
||||
|
||||
if(!reset) {
|
||||
var set_messages = function(r) {
|
||||
if(!r.exc) {
|
||||
// This function is defined in toolbar.js
|
||||
erpnext.toolbar.set_new_comments(r.message.unread_messages);
|
||||
|
||||
var show_in_circle = function(parent_id, msg) {
|
||||
var parent = $('#'+parent_id);
|
||||
if(parent) {
|
||||
if(msg) {
|
||||
parent.find('span:first').text(msg);
|
||||
parent.toggle(true);
|
||||
} else {
|
||||
parent.toggle(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
show_in_circle('unread_messages', r.message.unread_messages.length);
|
||||
show_in_circle('open_support_tickets', r.message.open_support_tickets);
|
||||
show_in_circle('things_todo', r.message.things_todo);
|
||||
show_in_circle('todays_events', r.message.todays_events);
|
||||
show_in_circle('open_tasks', r.message.open_tasks);
|
||||
show_in_circle('unanswered_questions', r.message.unanswered_questions);
|
||||
|
||||
} else {
|
||||
clearInterval(wn.updates.id);
|
||||
}
|
||||
}
|
||||
|
||||
wn.call({
|
||||
method: 'startup.startup.get_global_status_messages',
|
||||
callback: set_messages
|
||||
});
|
||||
|
||||
} else {
|
||||
erpnext.toolbar.set_new_comments(0);
|
||||
$('#unread_messages').toggle(false);
|
||||
}
|
||||
}
|
||||
|
||||
erpnext.startup.set_periodic_updates = function() {
|
||||
// Set interval for periodic updates of team messages
|
||||
wn.updates = {};
|
||||
|
||||
if(wn.updates.id) {
|
||||
clearInterval(wn.updates.id);
|
||||
}
|
||||
|
||||
wn.updates.id = setInterval(erpnext.update_messages, 60000);
|
||||
}
|
||||
|
||||
erpnext.set_user_background = function(src) {
|
||||
set_style(repl('#body_div { background: url("files/%(src)s") repeat;}', {src:src}))
|
||||
}
|
||||
|
||||
// start
|
||||
$(document).bind('startup', function() {
|
||||
erpnext.startup.start();
|
||||
});
|
||||
|
||||
// subject, sender, description
|
||||
erpnext.send_message = function(opts) {
|
||||
if(opts.btn) {
|
||||
$(opts.btn).start_working();
|
||||
}
|
||||
wn.call({
|
||||
method: 'website.send_message',
|
||||
args: opts,
|
||||
callback: function(r) {
|
||||
if(opts.btn) {
|
||||
$(opts.btn).done_working();
|
||||
}
|
||||
if(opts.callback)opts.callback(r)
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
erpnext.hide_naming_series = function() {
|
||||
if(cur_frm.fields_dict.naming_series) {
|
||||
hide_field('naming_series');
|
||||
if(cur_frm.doc.__islocal) {
|
||||
unhide_field('naming_series');
|
||||
}
|
||||
}
|
||||
}
|
||||
79
startup/startup.py
Normal file
79
startup/startup.py
Normal file
@@ -0,0 +1,79 @@
|
||||
# ERPNext - web based ERP (http://erpnext.com)
|
||||
# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import webnotes
|
||||
|
||||
def get_unread_messages():
|
||||
"returns unread (docstatus-0 messages for a user)"
|
||||
return webnotes.conn.sql("""\
|
||||
SELECT name, comment
|
||||
FROM `tabComment`
|
||||
WHERE comment_doctype IN ('My Company', 'Message')
|
||||
AND comment_docname = %s
|
||||
AND ifnull(docstatus,0)=0
|
||||
""", webnotes.user.name, as_list=1)
|
||||
|
||||
def get_open_support_tickets():
|
||||
"""Returns a count of open support tickets"""
|
||||
from webnotes.utils import cint
|
||||
open_support_tickets = webnotes.conn.sql("""\
|
||||
SELECT COUNT(*) FROM `tabSupport Ticket`
|
||||
WHERE status = 'Open'""")
|
||||
return open_support_tickets and cint(open_support_tickets[0][0]) or 0
|
||||
|
||||
def get_open_tasks():
|
||||
"""Returns a count of open tasks"""
|
||||
from webnotes.utils import cint
|
||||
return webnotes.conn.sql("""\
|
||||
SELECT COUNT(*) FROM `tabTask`
|
||||
WHERE status = 'Open'""")[0][0]
|
||||
|
||||
def get_things_todo():
|
||||
"""Returns a count of incomplete todos"""
|
||||
from webnotes.utils import cint
|
||||
incomplete_todos = webnotes.conn.sql("""\
|
||||
SELECT COUNT(*) FROM `tabToDo`
|
||||
WHERE IFNULL(checked, 0) = 0
|
||||
AND owner = %s""", webnotes.session.get('user'))
|
||||
return incomplete_todos and cint(incomplete_todos[0][0]) or 0
|
||||
|
||||
def get_todays_events():
|
||||
"""Returns a count of todays events in calendar"""
|
||||
from webnotes.utils import nowdate, cint
|
||||
todays_events = webnotes.conn.sql("""\
|
||||
SELECT COUNT(*) FROM `tabEvent`
|
||||
WHERE owner = %s
|
||||
AND event_type != 'Cancel'
|
||||
AND event_date = %s""", (
|
||||
webnotes.session.get('user'), nowdate()))
|
||||
return todays_events and cint(todays_events[0][0]) or 0
|
||||
|
||||
def get_unanswered_questions():
|
||||
return len(filter(lambda d: d[0]==0,
|
||||
webnotes.conn.sql("""select (select count(*) from tabAnswer
|
||||
where tabAnswer.question = tabQuestion.name) as answers from tabQuestion""")))
|
||||
|
||||
@webnotes.whitelist()
|
||||
def get_global_status_messages(arg=None):
|
||||
return {
|
||||
'unread_messages': get_unread_messages(),
|
||||
'open_support_tickets': get_open_support_tickets(),
|
||||
'things_todo': get_things_todo(),
|
||||
'todays_events': get_todays_events(),
|
||||
'open_tasks': get_open_tasks(),
|
||||
'unanswered_questions': get_unanswered_questions()
|
||||
}
|
||||
Reference in New Issue
Block a user