mirror of
https://github.com/frappe/erpnext.git
synced 2026-06-02 03:39:11 +00:00
first cut for lazy loading framework
This commit is contained in:
@@ -1,28 +0,0 @@
|
||||
[
|
||||
{
|
||||
'creation': '2011-06-09 16:14:42',
|
||||
'disabled': 'No',
|
||||
'docstatus': 0,
|
||||
'doctype': 'Module Def',
|
||||
'doctype_list': None,
|
||||
'file_list': None,
|
||||
'idx': None,
|
||||
'is_hidden': 'No',
|
||||
'last_updated_date': None,
|
||||
'modified': '2011-06-09 16:57:36',
|
||||
'modified_by': 'Administrator',
|
||||
'module_desc': None,
|
||||
'module_icon': None,
|
||||
'module_label': 'Home',
|
||||
'module_name': 'Home',
|
||||
'module_page': 'Event Updates',
|
||||
'module_seq': -1,
|
||||
'name': 'Home',
|
||||
'owner': 'Administrator',
|
||||
'parent': None,
|
||||
'parentfield': None,
|
||||
'parenttype': None,
|
||||
'trash_reason': None,
|
||||
'widget_code': None
|
||||
}
|
||||
]
|
||||
101
home/__init__.py
101
home/__init__.py
@@ -1,101 +0,0 @@
|
||||
import webnotes
|
||||
from webnotes import msgprint
|
||||
|
||||
feed_dict = {
|
||||
# Project
|
||||
'Project': ['[%(status)s]', '#000080'],
|
||||
|
||||
# Sales
|
||||
'Lead': ['%(lead_name)s', '#000080'],
|
||||
'Quotation': ['[%(status)s] To %(customer_name)s worth %(currency)s %(grand_total_export)s', '#4169E1'],
|
||||
'Sales Order': ['[%(status)s] To %(customer_name)s worth %(currency)s %(grand_total_export)s', '#4169E1'],
|
||||
|
||||
# Purchase
|
||||
'Supplier': ['%(supplier_name)s, %(supplier_type)s', '#6495ED'],
|
||||
'Purchase Order': ['[%(status)s] %(name)s To %(supplier_name)s for %(currency)s %(grand_total_import)s', '#4169E1'],
|
||||
|
||||
# Stock
|
||||
'Delivery Note': ['[%(status)s] To %(customer_name)s', '#4169E1'],
|
||||
|
||||
# Accounts
|
||||
'Journal Voucher': ['[%(voucher_type)s] %(name)s', '#4169E1'],
|
||||
'Payable Voucher': ['To %(supplier_name)s for %(currency)s %(grand_total_import)s', '#4169E1'],
|
||||
'Receivable Voucher':['To %(customer_name)s for %(currency)s %(grand_total_export)s', '#4169E1'],
|
||||
|
||||
# HR
|
||||
'Expense Voucher': ['[%(approval_status)s] %(name)s by %(employee_name)s', '#4169E1'],
|
||||
'Salary Slip': ['%(employee_name)s for %(month)s %(fiscal_year)s', '#4169E1'],
|
||||
'Leave Transaction':['%(leave_type)s for %(employee)s', '#4169E1'],
|
||||
|
||||
# Support
|
||||
'Customer Issue': ['[%(status)s] %(description)s by %(customer_name)s', '#000080'],
|
||||
'Maintenance Visit':['To %(customer_name)s', '#4169E1'],
|
||||
'Support Ticket': ['[%(status)s] %(subject)s', '#000080']
|
||||
}
|
||||
|
||||
feed_dict_color = {
|
||||
# Project
|
||||
'Project': '#000080',
|
||||
|
||||
# Sales
|
||||
'Lead': '#000080',
|
||||
'Quotation': '#4169E1',
|
||||
'Sales Order': '#4169E1',
|
||||
|
||||
# Purchase
|
||||
'Supplier': '#6495ED',
|
||||
'Purchase Order': '#4169E1',
|
||||
|
||||
# Stock
|
||||
'Delivery Note': '#4169E1',
|
||||
|
||||
# Accounts
|
||||
'Journal Voucher': '#4169E1',
|
||||
'Payable Voucher': '#4169E1',
|
||||
'Receivable Voucher': '#4169E1',
|
||||
|
||||
# HR
|
||||
'Expense Voucher': '#4169E1',
|
||||
'Salary Slip': '#4169E1',
|
||||
'Leave Transaction': '#4169E1',
|
||||
|
||||
# Support
|
||||
'Customer Issue': '#000080',
|
||||
'Maintenance Visit': '#4169E1',
|
||||
'Support Ticket': '#000080'
|
||||
}
|
||||
|
||||
def make_feed(doc, subject, color):
|
||||
"makes a new Feed record"
|
||||
#msgprint(subject)
|
||||
from webnotes.model.doc import Document
|
||||
webnotes.conn.sql("delete from tabFeed where doc_type=%s and doc_name=%s", (doc.doctype, doc.name))
|
||||
f = Document('Feed')
|
||||
f.doc_type = doc.doctype
|
||||
f.doc_name = doc.name
|
||||
f.subject = subject
|
||||
f.color = color
|
||||
f.save(1)
|
||||
|
||||
def update_feed1(doc):
|
||||
"adds a new feed"
|
||||
prop_rec = webnotes.conn.sql("select value from `tabProperty Setter` where doc_type = %s and property = 'subject'", (doc.doctype))
|
||||
if prop_rec:
|
||||
subject = prop_rec[0][0]
|
||||
else:
|
||||
rec = webnotes.conn.sql("select subject from tabDocType where name=%s", (doc.doctype))
|
||||
subject = rec[0][0]
|
||||
|
||||
subject, color = [subject, feed_dict_color.get(doc.doctype)]
|
||||
if subject:
|
||||
subject = subject % doc.fields
|
||||
make_feed(doc, subject, color)
|
||||
|
||||
def update_feed(doc, method=None):
|
||||
"adds a new feed"
|
||||
if method=='validate':
|
||||
return
|
||||
subject, color = feed_dict.get(doc.doctype, [None, None])
|
||||
if subject:
|
||||
subject = subject % doc.fields
|
||||
make_feed(doc, subject, color)
|
||||
@@ -1,86 +0,0 @@
|
||||
# Please edit this list and import only required elements
|
||||
import webnotes
|
||||
|
||||
from webnotes.utils import add_days, add_months, add_years, cint, cstr, date_diff, default_fields, flt, fmt_money, formatdate, generate_hash, getTraceback, get_defaults, get_first_day, get_last_day, getdate, has_common, month_name, now, nowdate, replace_newlines, sendmail, set_default, str_esc_quote, user_format, validate_email_add
|
||||
from webnotes.model import db_exists
|
||||
from webnotes.model.doc import Document, addchild, removechild, getchildren, make_autoname, SuperDocType
|
||||
from webnotes.model.doclist import getlist, copy_doclist
|
||||
from webnotes.model.code import get_obj, get_server_obj, run_server_obj, updatedb, check_syntax
|
||||
from webnotes import session, form, is_testing, msgprint, errprint
|
||||
|
||||
set = webnotes.conn.set
|
||||
sql = webnotes.conn.sql
|
||||
get_value = webnotes.conn.get_value
|
||||
in_transaction = webnotes.conn.in_transaction
|
||||
convert_to_lists = webnotes.conn.convert_to_lists
|
||||
|
||||
# -----------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
class DocType:
|
||||
def __init__(self,d,dl):
|
||||
self.doc, self.doclist = d,dl
|
||||
|
||||
# All roles of Role Master
|
||||
def get_all_roles(self):
|
||||
r_list=sql("select name from `tabRole` where name not in ('All','Guest','Administrator','Customer','Supplier') and docstatus != 2")
|
||||
if r_list[0][0]:
|
||||
r_list = [x[0] for x in r_list]
|
||||
return r_list
|
||||
|
||||
# Get all permissions for given role
|
||||
def get_permission(self,role):
|
||||
perm = sql("select distinct t1.`parent`, t1.`read`, t1.`write`, t1.`create`, t1.`submit`,t1.`cancel`,t1.`amend` from `tabDocPerm` t1, `tabDocType` t2 where t1.`role` ='%s' and t1.docstatus !=2 and ifnull(t1.permlevel, 0) = 0 and t1.`read` = 1 and t2.module != 'Recycle Bin' and t1.parent=t2.name " % role)
|
||||
return perm or ''
|
||||
|
||||
# Get roles for given user
|
||||
def get_user_roles(self,usr):
|
||||
r_list=sql("select role from `tabUserRole` where parent=%s and role not in ('All','Guest')",usr)
|
||||
if r_list:
|
||||
return [r[0] for r in r_list]
|
||||
else:
|
||||
return ''
|
||||
|
||||
# Update roles of given user
|
||||
def update_roles(self,arg):
|
||||
arg = eval(arg)
|
||||
sql("delete from `tabUserRole` where parenttype='Profile' and parent ='%s'" % (cstr(arg['usr'])))
|
||||
role_list = arg['role_list'].split(',')
|
||||
for r in role_list:
|
||||
pr=Document('UserRole')
|
||||
pr.parent = arg['usr']
|
||||
pr.parenttype = 'Profile'
|
||||
pr.role = r
|
||||
pr.parentfield = 'userroles'
|
||||
pr.save(1)
|
||||
sql("delete from __SessionCache where user=%s", cstr(arg['usr']))
|
||||
|
||||
# Save profile
|
||||
def save_profile(self,arg):
|
||||
arg = eval(arg)
|
||||
p = Document('Profile', session['user'])
|
||||
for k in arg:
|
||||
p.fields[k] = arg[k]
|
||||
p.save()
|
||||
|
||||
def get_login_url(self):
|
||||
return session['data']['login_from']
|
||||
|
||||
def get_user_info(self):
|
||||
|
||||
usr = sql("select count(name) from tabProfile where docstatus != 2 and name not in ('Guest','Administrator')")
|
||||
usr = usr and usr[0][0] or 0
|
||||
|
||||
ol = sql("select count(distinct t1.name) from tabProfile t1, tabSessions t2 where t1.name = t2.user and t1.name not in('Guest','Administrator') and TIMESTAMPDIFF(HOUR,t2.lastupdate,NOW()) <= 1 and t1.docstatus != 2 and t1.enabled=1")
|
||||
ol = ol and ol[0][0] or 0
|
||||
|
||||
ac = sql("select count(name) from tabProfile where enabled=1 and docstatus != 2 and name not in ('Guest', 'Administrator')")
|
||||
ac = ac and ac[0][0] or 0
|
||||
|
||||
inac = sql("select count(name) from tabProfile where (enabled=0 or enabled is null or enabled = '') and docstatus != 2 and name not in ('Guest','Administrator')")
|
||||
inac = inac and inac[0][0] or 0
|
||||
|
||||
return usr, ol, ac, inac
|
||||
|
||||
def get_sm_count(self) :
|
||||
return sql("select count(t1.parent) from tabUserRole t1, tabProfile t2 where t1.role='System Manager' and t1.parent = t2.name and t2.enabled=1")[0][0] or 0
|
||||
@@ -1,31 +0,0 @@
|
||||
# DocType, Company Control
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2010-08-08 17:08:55',
|
||||
'docstatus': 0,
|
||||
'modified': '2011-01-13 12:14:36',
|
||||
'modified_by': 'Administrator',
|
||||
'owner': 'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all DocType
|
||||
{
|
||||
'colour': 'White:FFF',
|
||||
'doctype': 'DocType',
|
||||
'issingle': 1,
|
||||
'module': 'Home',
|
||||
'name': '__common__',
|
||||
'section_style': 'Simple',
|
||||
'server_code': '\n\n\t# Update roles of given user\n\tdef update_roles(self,arg):\n\t\targ = eval(arg)\n\t\tsql("delete from `tabUserRole` where parenttype=\'Profile\' and parent =\'%s\'" % (cstr(arg[\'usr\'])))\n\t\trole_list = arg[\'role_list\'].split(\',\')\n\t\tmsgprint(sql("select role from tabUserRole where parent = \'%s\'" % cstr(arg[\'usr\'])))\n\t\tmsgprint(role_list)\n\t\tfor r in role_list:\n\t\t\tpr=Document(\'UserRole\')\n\t\t\tpr.parent = arg[\'usr\']\n\t\t\tpr.parenttype = \'Profile\'\n\t\t\tpr.role = r\n\t\t\tpr.parentfield = \'userroles\'\n\t\t\tpr.save(1)\n\t\tmsgprint(sql("select role from tabUserRole where parent = \'%s\'" % cstr(arg[\'usr\'])))\n\n\n # Create New Profile\n # ====================\n\tdef create_new_profile(self, arg):\n\t\tp = Document(\'Profile\')\n\t\tp.first_name = arg.get(\'first_name\') or arg.get(\'email_id\')\n\t\tp.last_name = arg.get(\'last_name\')\n\t\tp.email = arg.get(\'email_id\')\n\t\tp.name = arg.get(\'email_id\')\n\t\tp.user_type = arg.get(\'user_type\') or \'System User\'\n\t\tp.enabled = 0\t\n\t\tp.save(new=1)\n\t\tp_obj = get_obj(\'Profile\', p.name)\n\t\tp_obj.on_update()',
|
||||
'server_code_error': ' ',
|
||||
'version': 13
|
||||
},
|
||||
|
||||
# DocType, Company Control
|
||||
{
|
||||
'doctype': 'DocType',
|
||||
'name': 'Company Control'
|
||||
}
|
||||
]
|
||||
@@ -1,22 +0,0 @@
|
||||
# Please edit this list and import only required elements
|
||||
import webnotes
|
||||
|
||||
from webnotes.utils import add_days, add_months, add_years, cint, cstr, date_diff, default_fields, flt, fmt_money, formatdate, generate_hash, getTraceback, get_defaults, get_first_day, get_last_day, getdate, has_common, month_name, now, nowdate, replace_newlines, sendmail, set_default, str_esc_quote, user_format, validate_email_add
|
||||
from webnotes.model import db_exists
|
||||
from webnotes.model.doc import Document, addchild, removechild, getchildren, make_autoname, SuperDocType
|
||||
from webnotes.model.doclist import getlist, copy_doclist
|
||||
from webnotes.model.code import get_obj, get_server_obj, run_server_obj, updatedb, check_syntax
|
||||
from webnotes import session, form, is_testing, msgprint, errprint
|
||||
|
||||
set = webnotes.conn.set
|
||||
sql = webnotes.conn.sql
|
||||
get_value = webnotes.conn.get_value
|
||||
in_transaction = webnotes.conn.in_transaction
|
||||
convert_to_lists = webnotes.conn.convert_to_lists
|
||||
|
||||
# -----------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
class DocType:
|
||||
def __init__(self,d,dl):
|
||||
self.doc, self.doclist = d, dl
|
||||
@@ -1,73 +0,0 @@
|
||||
# DocType, Feed
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2011-04-08 10:50:41',
|
||||
'docstatus': 0,
|
||||
'modified': '2011-04-05 09:16:57',
|
||||
'modified_by': 'Administrator',
|
||||
'owner': 'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all DocType
|
||||
{
|
||||
'autoname': '_FEED.#####',
|
||||
'colour': 'White:FFF',
|
||||
'doctype': 'DocType',
|
||||
'module': 'Home',
|
||||
'name': '__common__',
|
||||
'section_style': 'Simple',
|
||||
'show_in_menu': 0,
|
||||
'version': 1
|
||||
},
|
||||
|
||||
# These values are common for all DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldtype': 'Data',
|
||||
'name': '__common__',
|
||||
'parent': 'Feed',
|
||||
'parentfield': 'fields',
|
||||
'parenttype': 'DocType',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocType, Feed
|
||||
{
|
||||
'doctype': 'DocType',
|
||||
'name': 'Feed'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'doc_type',
|
||||
'idx': 1,
|
||||
'label': 'Doc Type'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'doc_name',
|
||||
'idx': 2,
|
||||
'label': 'Doc Name'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'subject',
|
||||
'idx': 3,
|
||||
'label': 'Subject'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'color',
|
||||
'idx': 4,
|
||||
'label': 'Color'
|
||||
}
|
||||
]
|
||||
@@ -1,387 +0,0 @@
|
||||
# Please edit this list and import only required elements
|
||||
import webnotes
|
||||
|
||||
from webnotes.utils import add_days, add_months, add_years, cint, cstr, date_diff, default_fields, flt, fmt_money, formatdate, generate_hash, getTraceback, get_defaults, get_first_day, get_last_day, getdate, has_common, month_name, now, nowdate, replace_newlines, sendmail, set_default, str_esc_quote, user_format, validate_email_add
|
||||
from webnotes.model.doc import Document, addchild, removechild, getchildren, make_autoname, SuperDocType
|
||||
from webnotes import session, msgprint, errprint
|
||||
|
||||
sql = webnotes.conn.sql
|
||||
convert_to_lists = webnotes.conn.convert_to_lists
|
||||
|
||||
try: import json
|
||||
except: import simplejson as json
|
||||
|
||||
# -----------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
class DocType:
|
||||
def __init__(self,d,dl):
|
||||
self.doc, self.doclist = d,dl
|
||||
|
||||
# --------------------------------------------------------------------------------------------------------
|
||||
# ------------------------------------- Home page module details -----------------------------------------
|
||||
|
||||
def delete_cache(self):
|
||||
sql("delete from __DocTypeCache")
|
||||
com = sql("select abbr, name from tabCompany")
|
||||
for d in com:
|
||||
sql("update `tabCompany` set receivables_group = '%s' where (receivables_group = '%s' or receivables_group = '' or receivables_group is null) and name = '%s'" % ('Accounts Receivable - '+cstr(d[0]), 'Accounts Receivables - '+cstr(d[0]), d[1]))
|
||||
sql("update `tabCompany` set payables_group = '%s' where (payables_group = '%s' or payables_group = '' or payables_group is null) and name = '%s'" % ('Accounts Payable - '+cstr(d[0]), 'Accounts Payables - '+cstr(d[0]), d[1]))
|
||||
|
||||
def get_modules(self):
|
||||
rl = webnotes.user.get_roles()
|
||||
ml = sql("select distinct t1.name, t1.module_icon, t1.module_label, t1.module_desc, t1.module_page from `tabModule Def` t1, `tabModule Def Role` t2 where t2.role in ('%s') and t1.disabled !='Yes' and ifnull(t1.is_hidden, 'No') != 'Yes' and t1.name = t2.parent order by t1.module_seq asc" % "','".join(rl), as_dict=1)
|
||||
return ml
|
||||
|
||||
def get_login_url(self):
|
||||
return session['data'].get('login_from', '')
|
||||
|
||||
def get_module_details(self,m):
|
||||
ret = {}
|
||||
ret['il'] = sql('select doc_type, doc_name, display_name, icon, description, fields, click_function, idx from `tabModule Def Item` where parent=%s and ifnull(`hide`,0)=0 order by idx asc', m, as_dict=1)
|
||||
ret['wl'] = sql('select widget_code from `tabModule Def` where name =%s', m)[0][0] or ''
|
||||
ret['custom_reports'] = sql('''
|
||||
SELECT DISTINCT t1.criteria_name AS `display_name`, t1.description, t1.doc_type AS `doc_name`, 'Custom Reports' AS `doc_type`
|
||||
FROM `tabSearch Criteria` t1, `tabDocPerm` t2
|
||||
WHERE t1.module = "%s"
|
||||
AND IFNULL(t1.disabled,0) = 0
|
||||
AND (t1.doc_type=t2.parent OR t1.parent_doc_type = t2.parent)
|
||||
AND t2.permlevel = 0
|
||||
AND t2.read=1
|
||||
AND t2.role IN ("%s")
|
||||
AND ifnull(standard,"No")="No"''' % (m, '", "'.join(webnotes.user.get_roles())), as_dict=1)
|
||||
return ret
|
||||
|
||||
# ----------------------------------------------------------------------------------------------------------------
|
||||
# ----------------------------------------------- Home page updates ----------------------------------------------
|
||||
|
||||
def get_events_list(self):
|
||||
import webnotes, webnotes.utils
|
||||
from webnotes.widgets.event import get_cal_events
|
||||
|
||||
dl = get_cal_events(nowdate(), add_days(nowdate(), 7))
|
||||
el = []
|
||||
for d in dl:
|
||||
#el.append([d.name, d.event_date, d.event_hour, d.event_name, d.description or '', d.ref_type or '', d.ref_name or '', d.owner])
|
||||
dict = {
|
||||
'name': d.name,
|
||||
'event_date': d.event_date,
|
||||
'event_hour': d.event_hour,
|
||||
'event_name': d.event_name,
|
||||
'description': d.description,
|
||||
'notes': d.notes,
|
||||
'event_type': d.event_type,
|
||||
'ref_type': d.ref_type,
|
||||
'ref_name': d.ref_name,
|
||||
'owner' : d.owner
|
||||
}
|
||||
|
||||
el.append(dict)
|
||||
return el
|
||||
|
||||
|
||||
def get_activity_list(self):
|
||||
out = {}
|
||||
import webnotes
|
||||
rt = webnotes.user.can_read
|
||||
|
||||
dt_list = [d[0] for d in sql("select distinct t2.name from tabDocField t1, tabDocType t2 where t1.fieldname='status' and t1.docstatus=0 and (t2.istable is null or t2.istable = 0) and t1.parent = t2.name")]
|
||||
if not dt_list:
|
||||
return out
|
||||
|
||||
# get list of activity dt
|
||||
for dt in dt_list:
|
||||
if dt in rt:
|
||||
out[dt] = {}
|
||||
# get status list
|
||||
sl = sql("select distinct status from `tab%s`" % dt)
|
||||
|
||||
for s in sl:
|
||||
if s[0]:
|
||||
# get count
|
||||
cnt = sql("select count(*) from `tab%s` where status = '%s' and modified > '%s'" % (dt, s[0], add_days(nowdate(), -7)))[0][0]
|
||||
out[dt][s[0]] = cint(cnt)
|
||||
return out
|
||||
|
||||
def send_feedback(self, args):
|
||||
args = json.loads(args)
|
||||
|
||||
fb_sender = sql("select concat_ws(' ',first_name, last_name), email from tabProfile where name=%s", session['user'])
|
||||
fb_subject = 'Feedback : ' + args['subject']
|
||||
|
||||
|
||||
fb_msg = '''
|
||||
<div style="font-size:14px; padding:8px; border:1px solid #DDF">
|
||||
<div style="margin-bottom:16px">%s wrote,</div>
|
||||
<div>%s</div>
|
||||
</div>
|
||||
''' % (fb_sender[0][0], args['feedback'])
|
||||
|
||||
sendmail('info@webnotestech.com', fb_sender[0][1], msg = fb_msg, subject=args['subject'],parts=[], cc=[], attach=[])
|
||||
|
||||
def get_dt_help(self,dt):
|
||||
return sql("select description from tabDocType where name=%s",dt)[0][0] or ''
|
||||
|
||||
# ----------------------------------------------------------------------------------------
|
||||
def welcome_done(self):
|
||||
if cint(get_defaults().get('welcome_done')):
|
||||
return 'Yes'
|
||||
else:
|
||||
return 'No'
|
||||
|
||||
def set_welcome_done(self):
|
||||
set_default('welcome_done', '1')
|
||||
|
||||
# Check Complete Registration
|
||||
# ----------------------
|
||||
def registration_complete(self):
|
||||
if cint(get_defaults().get('registration_complete')):
|
||||
return 'Yes'
|
||||
else:
|
||||
return 'No'
|
||||
|
||||
# get dashboard counts
|
||||
# --------------------
|
||||
def get_wip_counts(self):
|
||||
#dtl = ['Lead', 'Enquiries', 'Sales Order', 'Invoices', 'Indent', 'Purchase Order', 'Bills', 'Tasks', 'Delivery Note', 'Maintenance']
|
||||
can_read_dt = ['Lead', 'Enquiry', 'Sales Order', 'Receivable Voucher', 'Indent', 'Purchase Order', 'Payable Voucher', 'Delivery Note', 'Task', 'Serial No']
|
||||
dt = {}
|
||||
for d in can_read_dt:
|
||||
args = {}
|
||||
|
||||
# if Lead
|
||||
if d=='Lead':
|
||||
args = {'To follow up':sql("select count(name) from tabLead where status!='Converted' and status!='Lead Lost' and status!='Not Interested'")}
|
||||
|
||||
# if Enquiry
|
||||
elif d=='Enquiry':
|
||||
args['Quotations to be sent'] = sql("select count(distinct(t2.name)) from `tabQuotation`t1, `tabEnquiry`t2 where t1.enq_no!=t2.name and t2.docstatus=1")
|
||||
args['To follow up'] = sql("select count(distinct(t2.name)) from `tabQuotation`t1, `tabEnquiry`t2 where t1.enq_no=t2.name and t2.docstatus=1 and t1.docstatus=1")
|
||||
|
||||
# if Sales Order
|
||||
elif d=='Sales Order':
|
||||
args['To be delivered'] = sql("select count(name) from `tabSales Order` where ifnull(per_delivered,0)<100 and delivery_date>now() and docstatus=1")
|
||||
args['To be billed'] = sql("select count(name) from `tabSales Order` where ifnull(per_billed,0)<100 and docstatus=1")
|
||||
args['Overdue'] = sql("select count(name) from `tabSales Order` where ifnull(per_delivered,0)<100 and delivery_date<now() and docstatus=1")
|
||||
args['To be submitted'] = sql("select count(name) from `tabSales Order` where docstatus=0 and status='Draft'") #Draft
|
||||
|
||||
# if Receivable Voucher
|
||||
elif d=='Receivable Voucher':
|
||||
args['To receive payment'] = sql("select count(name) from `tabReceivable Voucher` where docstatus=1 and due_date>now() and outstanding_amount!=0")
|
||||
args['Overdue'] = sql("select count(name) from `tabReceivable Voucher` where docstatus=1 and due_date<now() and outstanding_amount!=0")
|
||||
args['To be submitted'] = sql("select count(name) from `tabReceivable Voucher` where docstatus=0") #Draft
|
||||
|
||||
# if Indent
|
||||
elif d=='Indent':
|
||||
args['Purchase Order to be made'] = sql("select count(name) from `tabIndent` where ifnull(per_ordered,0)<100 and docstatus=1")
|
||||
args['To be submitted'] = sql("select count(name) from `tabIndent` where status='Draft'") #Draft
|
||||
|
||||
# if Purchase Order
|
||||
elif d=='Purchase Order':
|
||||
args['To receive items'] = sql("select count(name) from `tabPurchase Order` where ifnull(per_received,0)<100 and docstatus=1")
|
||||
args['To be billed'] = sql("select count(name) from `tabPurchase Order` where ifnull(per_billed,0)<100 and docstatus=1")
|
||||
args['To be submitted'] = sql("select count(name) from `tabPurchase Order` where status='Draft'") #Draft
|
||||
|
||||
# if Payable Voucher
|
||||
elif d=='Payable Voucher':
|
||||
args['To be paid'] = sql("select count(name) from `tabPayable Voucher` where docstatus=1 and outstanding_amount!=0")
|
||||
args['To be submitted'] = sql("select count(name) from `tabPayable Voucher` where docstatus=0") #Draft
|
||||
|
||||
# if Delivery Note
|
||||
elif d=='Delivery Note':
|
||||
args['To be submitted'] = sql("select count(name) from `tabDelivery Note` where status='Draft' and docstatus=0")
|
||||
args['To be billed'] = sql("select count(name) from `tabDelivery Note` where docstatus=1 and docstatus=1 and ifnull(per_billed,0)<100")
|
||||
|
||||
# if Tasks
|
||||
elif d=='Task':
|
||||
args = {'Open': sql("select count(name) from `tabTicket` where status='Open'")}
|
||||
|
||||
# if Serial No
|
||||
elif d=='Serial No':
|
||||
args['AMC expiring this month'] = sql("select count(name) from `tabSerial No` where docstatus!=2 and maintenance_status = 'Under AMC' and status!='Scrapped' and status!='Not in Use' and month(now()) = month(amc_expiry_date) and year(now()) = year(amc_expiry_date)")
|
||||
args['Warranty expiring this month'] = sql("select count(name) from `tabSerial No` where docstatus!=2 and maintenance_status = 'Under Warranty' and status!='Scrapped' and status!='Not in Use' and month(now()) = month(ifnull(warranty_expiry_date,0)) and year(now())=year(ifnull(warranty_expiry_date,0))")
|
||||
|
||||
for a in args:
|
||||
args[a] = args[a] and args[a][0][0] or 0
|
||||
|
||||
dt[d] = args
|
||||
return dt
|
||||
|
||||
# -------------------------------------------------------------------------------------------------------
|
||||
|
||||
def get_todo_count(self):
|
||||
count = sql("select count(distinct name) from `tabToDo Item` where owner=%s", session['user'])
|
||||
count = count and count[0][0] or 0
|
||||
return count
|
||||
|
||||
def get_todo_list(self):
|
||||
return convert_to_lists(sql("select name, description, date, priority,checked from `tabToDo Item` where owner=%s order by field(priority,'High','Medium','Low') asc, date asc", session['user']))
|
||||
|
||||
def add_todo_item(self,args):
|
||||
args = json.loads(args)
|
||||
|
||||
d = Document('ToDo Item', args.get('name') or None)
|
||||
d.description = args['description']
|
||||
d.date = args['date']
|
||||
d.priority = args['priority']
|
||||
d.checked = args.get('checked', 0)
|
||||
d.owner = session['user']
|
||||
d.save(not args.get('name') and 1 or 0)
|
||||
|
||||
return d.name
|
||||
|
||||
def remove_todo_item(self,nm):
|
||||
sql("delete from `tabToDo Item` where name = %s",nm)
|
||||
|
||||
# -------------------------------------------------------------------------------------------------------
|
||||
|
||||
def get_status_details(self, arg=''):
|
||||
# no of users online
|
||||
count = sql("select count(distinct user) from tabSessions t2 where user not in ('Guest','Administrator') and TIMESTAMPDIFF(HOUR,t2.lastupdate,NOW()) <= 1")
|
||||
|
||||
# unread messages
|
||||
unread = sql("select count(t1.name) from `tabMail` t1, `tabMail Participant Details` t2 where t2.participant_name = '%s' and t2.parent = t1.name and (t2.read_status = 'No' or t2.read_status is NULL) and (t2.delete_status = 'No' or t2.delete_status is NULL) and t1.last_updated_by != t2.participant_name" % arg)
|
||||
|
||||
# system messages
|
||||
msg_id = webnotes.conn.get_global('system_message_id')
|
||||
msg = ''
|
||||
|
||||
if msg_id and msg_id != webnotes.conn.get_global('system_message_id', session['user']):
|
||||
msg = webnotes.conn.get_global('system_message')
|
||||
|
||||
return {'user_count': count and cint(count[0][0]) or 0, 'unread': unread and cint(unread[0][0]) or 0, 'system_message':msg}
|
||||
|
||||
# -------------------------------------------------------------------------------------------------------
|
||||
|
||||
def dismiss_message(self, arg=''):
|
||||
msg_id = webnotes.conn.get_global('system_message_id')
|
||||
webnotes.conn.set_global('system_message_id', msg_id, session['user'])
|
||||
|
||||
# -------------------------------------------------------------------------------------------------------
|
||||
|
||||
def get_todo_reminder(self):
|
||||
return convert_to_lists(sql("select name, description, date, priority,checked from `tabToDo Item` where owner=%s and date=%s and checked=1 order by priority, date", (session['user'], nowdate())))
|
||||
|
||||
# get user details
|
||||
def get_users(self):
|
||||
ret = {}
|
||||
ret['usr'] = convert_to_lists(sql("select distinct name, concat_ws(' ', first_name, last_name), ifnull(messanger_status,'Available') from tabProfile where name=%s", session['user']))
|
||||
ret['on'] = convert_to_lists(sql("select distinct t1.name, concat_ws(' ', t1.first_name, t1.last_name), ifnull(t1.messanger_status,'Available') from tabProfile t1, tabSessions t2 where t1.name = t2.user and t1.name not in('Guest',%s) and TIMESTAMPDIFF(HOUR,t2.lastupdate,NOW()) <= 1", session['user']))
|
||||
ret['off'] = convert_to_lists(sql("select distinct t1.name, concat_ws(' ', t1.first_name, t1.last_name), ifnull(t1.messanger_status,'Offline') from tabProfile t1, tabSessions t2 where t1.name != t2.user and t1.name not in('Guest',%s) and t1.name not in(select distinct t1.name from tabProfile t1, tabSessions t2 where t1.name = t2.user and t1.name not in('Guest',%s) and (t1.messanger_status !='Invisible' or t1.messanger_status is null) and TIMESTAMPDIFF(HOUR,t2.lastupdate,NOW()) <= 1)", (session['user'], session['user'])))
|
||||
|
||||
return ret
|
||||
|
||||
# Delete event
|
||||
def delete_event(self,id):
|
||||
sql("delete from tabEvent where name=%s", id)
|
||||
|
||||
# edit event
|
||||
def edit_event(self,arg):
|
||||
arg = json.loads(arg)
|
||||
d = Document('Event', arg.get('name') or None)
|
||||
for k in arg:
|
||||
d.fields[k] = str(arg[k])
|
||||
d.save(not arg.get('name') and 1 or 0)
|
||||
|
||||
# -------------------------------------------------------------------------------------------------------
|
||||
# module settings
|
||||
# -------------------------------------------------------------------------------------------------------
|
||||
def get_module_order(self):
|
||||
show_list = ['Home','Setup','Accounts','Selling','Buying','Support','Stock','HR','Projects','Analysis','Production']
|
||||
ml = filter(lambda x: x[0] in show_list, \
|
||||
sql("select name, module_label, module_seq, is_hidden from `tabModule Def` where docstatus<2 order by module_seq asc, module_label asc"))
|
||||
return convert_to_lists(ml)
|
||||
|
||||
def set_module_order(self,arg):
|
||||
arg = eval(arg)
|
||||
for k in arg:
|
||||
sql("update `tabModule Def` set module_seq = %s, is_hidden = %s where name = %s", (cint(arg[k]['module_seq']) + 1, arg[k]['is_hidden'], k))
|
||||
|
||||
# -------------------------------------------------------------------------------------------------------
|
||||
|
||||
def get_bd_list(self):
|
||||
bl = convert_to_lists(sql("select name,concat_ws(' ',first_name,last_name),birth_date from tabProfile where (birth_date is not null and birth_date != '') and (enabled is not null and enabled !='')"))
|
||||
|
||||
nd = nowdate().split('-')
|
||||
d = cint(nd[2])
|
||||
m = cint(nd[1])
|
||||
|
||||
tb = []
|
||||
for b in bl:
|
||||
if b[2] and b[2].find('-') != -1:
|
||||
if cint(b[2].split('-')[2]) == d and cint(b[2].split('-')[1]) == m:
|
||||
tb.append(b)
|
||||
|
||||
return tb
|
||||
|
||||
# obtain account id for webforms
|
||||
def get_acc_id(self):
|
||||
acc_id = sql("select value from `tabSingles` where field='account_id' and doctype='Control Panel'")
|
||||
acc_id = acc_id and acc_id[0][0] or ''
|
||||
if acc_id:
|
||||
return cstr(acc_id)
|
||||
else:
|
||||
msgprint("Account Id not specified")
|
||||
raise Exception
|
||||
|
||||
#update serial no status
|
||||
def update_serial_status(self, lst, status):
|
||||
lst11=[]
|
||||
for y1 in lst:
|
||||
sql("update `tabSerial No` set maintenance_status = %s where name=%s", (status,y1))
|
||||
lst11.append(y1)
|
||||
msgprint("Status updated as '"+status+"' for "+cstr(lst11))
|
||||
|
||||
# chk to set serial no status as 'Out of warranty'
|
||||
def set_for_out_of_warranty(self):
|
||||
chk_for_out_of_wrnty = sql("select name from `tabSerial No` where ifnull(warranty_expiry_date, '2200-12-12') < CURDATE() and ifnull(warranty_expiry_date, '0000-00-00') != '0000-00-00' and ifnull(amc_expiry_date, '0000-00-00') ='0000-00-00' and ifnull(maintenance_status, '') != 'Out of Warranty'")
|
||||
if chk_for_out_of_wrnty:
|
||||
lst1 = [x1[0] for x1 in chk_for_out_of_wrnty]
|
||||
self.update_serial_status(lst1, 'Out Of Warranty')
|
||||
|
||||
# chk to set serial no status as 'Out of amc'
|
||||
def set_for_out_of_amc(self):
|
||||
chk_for_out_of_amc = sql("select name from `tabSerial No` where ifnull(warranty_expiry_date, '0000-00-00')< CURDATE() and ifnull(amc_expiry_date, '2200-12-12') < CURDATE() and ifnull(amc_expiry_date, '0000-00-00') !='0000-00-00' and ifnull(maintenance_status, '') !='Out of AMC'")
|
||||
if chk_for_out_of_amc:
|
||||
lst2 = [x2[0] for x2 in chk_for_out_of_amc]
|
||||
self.update_serial_status(lst2, 'Out Of AMC')
|
||||
|
||||
# chk to set serial no status as 'under amc'
|
||||
def set_for_under_amc(self):
|
||||
chk_for_under_amc = sql("select name from `tabSerial No` where ifnull(warranty_expiry_date, '0000-00-00')< CURDATE() and ifnull(amc_expiry_date, '2200-12-12') >= CURDATE() and ifnull(amc_expiry_date, '0000-00-00') !='0000-00-00' and ifnull(maintenance_status, '') !='Under AMC'")
|
||||
if chk_for_under_amc:
|
||||
lst3 = [x3[0] for x3 in chk_for_under_amc]
|
||||
self.update_serial_status(lst3, 'Under AMC')
|
||||
|
||||
# chk to set serial no status as 'under warranty'
|
||||
def set_for_under_warranty(self):
|
||||
chk_for_under_wrnty = sql("select name from `tabSerial No` where ifnull(warranty_expiry_date, '2200-12-12') >= CURDATE() and ifnull(warranty_expiry_date, '0000-00-00') != '0000-00-00' and ifnull(amc_expiry_date, '0000-00-00') ='0000-00-00' and ifnull(maintenance_status, '') != 'Under Warranty'")
|
||||
if chk_for_under_wrnty:
|
||||
lst4 = [x4[0] for x4 in chk_for_under_wrnty]
|
||||
self.update_serial_status(lst4, 'Under Warranty')
|
||||
|
||||
# check maintenance status for all serial nos only for 1st login each day
|
||||
def set_serial_no_status(self):
|
||||
|
||||
chk_serial_no_update_date = webnotes.conn.get_global('maintenance_status_update_date')
|
||||
|
||||
# check status only for 1st login each day.... if maintenance date already updated means it is checked
|
||||
if getdate(chk_serial_no_update_date) != nowdate():
|
||||
# chk to set serial no status as 'Out of warranty'
|
||||
self.set_for_out_of_warranty()
|
||||
|
||||
# chk to set serial no status as 'Out of amc'
|
||||
self.set_for_out_of_amc()
|
||||
|
||||
# chk to set serial no status as 'under amc'
|
||||
self.set_for_under_amc()
|
||||
|
||||
# chk to set serial no status as 'under warranty'
|
||||
self.set_for_under_warranty()
|
||||
|
||||
#set maintenance_status_update_date
|
||||
webnotes.conn.set_global('maintenance_status_update_date', nowdate())
|
||||
|
||||
# get user fullname
|
||||
def get_user_fullname(self,usr):
|
||||
return sql("select concat_ws(' ',first_name, last_name) from tabProfile where name=%s", usr)[0][0] or ''
|
||||
@@ -1,55 +0,0 @@
|
||||
# DocType, Home Control
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2009-07-09 16:32:49',
|
||||
'docstatus': 0,
|
||||
'modified': '2010-12-24 17:08:55',
|
||||
'modified_by': 'nabin@webnotestech.com',
|
||||
'owner': 'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all DocType
|
||||
{
|
||||
'colour': 'White:FFF',
|
||||
'doctype': 'DocType',
|
||||
'issingle': 1,
|
||||
'module': 'Home',
|
||||
'name': '__common__',
|
||||
'section_style': 'Simple',
|
||||
'server_code_error': ' ',
|
||||
'show_in_menu': 0,
|
||||
'version': 6
|
||||
},
|
||||
|
||||
# These values are common for all DocPerm
|
||||
{
|
||||
'create': 1,
|
||||
'doctype': 'DocPerm',
|
||||
'name': '__common__',
|
||||
'parent': 'Home Control',
|
||||
'parentfield': 'permissions',
|
||||
'parenttype': 'DocType',
|
||||
'permlevel': 0,
|
||||
'read': 1,
|
||||
'role': 'Guest',
|
||||
'write': 1
|
||||
},
|
||||
|
||||
# DocType, Home Control
|
||||
{
|
||||
'doctype': 'DocType',
|
||||
'name': 'Home Control'
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'doctype': 'DocPerm'
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'doctype': 'DocPerm'
|
||||
}
|
||||
]
|
||||
@@ -1,45 +0,0 @@
|
||||
import webnotes
|
||||
|
||||
from webnotes.utils import nowdate
|
||||
from webnotes.model.doc import Document
|
||||
from webnotes.model.code import get_obj
|
||||
from webnotes import session, form, msgprint
|
||||
|
||||
sql = webnotes.conn.sql
|
||||
|
||||
try: import json
|
||||
except: import simplejson as json
|
||||
|
||||
# -----------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
class DocType:
|
||||
def __init__(self,d,dl):
|
||||
self.doc, self.doclist = d, dl
|
||||
|
||||
def add_comment(self,args):
|
||||
import time
|
||||
args = eval(args)
|
||||
if(args['comment']):
|
||||
cmt = Document('Comment Widget Record')
|
||||
for arg in args:
|
||||
cmt.fields[arg] = args[arg]
|
||||
cmt.comment_date = nowdate()
|
||||
cmt.comment_time = time.strftime('%H:%M')
|
||||
cmt.save(1)
|
||||
|
||||
try:
|
||||
get_obj('Feed Control').upate_comment_in_feed(args['comment_doctype'], args['comment_docname'])
|
||||
except:
|
||||
pass
|
||||
|
||||
else:
|
||||
raise Exception
|
||||
|
||||
def remove_comment(self, args):
|
||||
args = json.loads(args)
|
||||
sql("delete from `tabComment Widget Record` where name=%s",args['id'])
|
||||
|
||||
try:
|
||||
get_obj('Feed Control').upate_comment_in_feed(args['dt'], args['dn'])
|
||||
except: pass
|
||||
@@ -1,32 +0,0 @@
|
||||
# DocType, Widget Control
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2010-08-08 17:09:30',
|
||||
'docstatus': 0,
|
||||
'modified': '2010-09-20 14:06:57',
|
||||
'modified_by': 'Administrator',
|
||||
'owner': 'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all DocType
|
||||
{
|
||||
'colour': 'White:FFF',
|
||||
'doctype': 'DocType',
|
||||
'issingle': 1,
|
||||
'istable': 0,
|
||||
'module': 'Home',
|
||||
'name': '__common__',
|
||||
'section_style': 'Simple',
|
||||
'server_code_error': ' ',
|
||||
'show_in_menu': 0,
|
||||
'version': 27
|
||||
},
|
||||
|
||||
# DocType, Widget Control
|
||||
{
|
||||
'doctype': 'DocType',
|
||||
'name': 'Widget Control'
|
||||
}
|
||||
]
|
||||
BIN
home/page/.DS_Store
vendored
BIN
home/page/.DS_Store
vendored
Binary file not shown.
@@ -1,12 +0,0 @@
|
||||
div.dashboard_table td {
|
||||
width: 50%;
|
||||
}
|
||||
|
||||
div.dashboard-title {
|
||||
font-weight: bold;
|
||||
padding: '3px 0px';
|
||||
}
|
||||
|
||||
div.dashboard-graph {
|
||||
height: 180px;
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
<div class="layout_wrapper dashboard">
|
||||
<div class="header"></div>
|
||||
<div class="body">
|
||||
<!-- 4x2 table to show the dashboards-->
|
||||
<div class="help_box">Loading...</div>
|
||||
<div class="dashboard_table"></div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -1,142 +0,0 @@
|
||||
pscript.onload_dashboard = function() {
|
||||
// load jqplot
|
||||
$.scriptPath = 'js/'
|
||||
$.require(['jquery/jquery.jqplot.min.js',
|
||||
'jquery/jqplot-plugins/jqplot.barRenderer.js',
|
||||
'jquery/jqplot-plugins/jqplot.canvasAxisTickRenderer.min.js',
|
||||
'jquery/jqplot-plugins/jqplot.canvasTextRenderer.min.js',
|
||||
'jquery/jqplot-plugins/jqplot.categoryAxisRenderer.min.js']);
|
||||
|
||||
|
||||
pscript.dashboard_settings = {
|
||||
company: sys_defaults.company,
|
||||
start: dateutil.obj_to_str(dateutil.add_days(new Date(), -180)),
|
||||
end: dateutil.obj_to_str(new Date()),
|
||||
interval: 30
|
||||
}
|
||||
|
||||
var ph = new PageHeader($('.dashboard .header').get(0), 'Dashboard');
|
||||
var db = new Dashboard();
|
||||
|
||||
ph.add_button('Settings', db.show_settings);
|
||||
|
||||
db.refresh();
|
||||
|
||||
}
|
||||
|
||||
Dashboard = function() {
|
||||
var me = this;
|
||||
$.extend(me, {
|
||||
refresh: function() {
|
||||
$('.dashboard .help_box').css('display', 'block');
|
||||
$c_page('home', 'dashboard', 'load_dashboard', JSON.stringify(pscript.dashboard_settings), function(r,rt) {
|
||||
$('.dashboard .help_box').css('display', 'none');
|
||||
me.render(r.message);
|
||||
})
|
||||
},
|
||||
|
||||
render: function(data) {
|
||||
$('.dashboard_table').html('');
|
||||
var t = make_table($('.dashboard_table').get(0), 4, 2, '100%', ['50%', '50%'], {padding: '5px'});
|
||||
var ridx=0; var cidx=0;
|
||||
for(var i=0; i< data.length; i++) {
|
||||
// switch columns and rows
|
||||
if(cidx==2) { cidx=0; ridx++}
|
||||
|
||||
// give an id!
|
||||
var cell = $td(t,ridx,cidx);
|
||||
var title = $a(cell, 'div', 'dashboard-title', '', data[i][0].title);
|
||||
var parent = $a(cell, 'div', 'dashboard-graph');
|
||||
if(data[i][0].comment);
|
||||
var comment = $a(cell, 'div', 'comment', '', data[i][0].comment)
|
||||
|
||||
parent.id = '_dashboard' + ridx + '-' + cidx;
|
||||
|
||||
// render graph
|
||||
me.render_graph(parent.id, data[i][1], data[i][0].fillColor);
|
||||
cidx++;
|
||||
}
|
||||
},
|
||||
|
||||
render_graph: function(parent, values, fillColor) {
|
||||
var vl = [];
|
||||
$.each(values, function(i,v) {
|
||||
vl.push([dateutil.str_to_user(v[0]), v[1]]);
|
||||
});
|
||||
$.jqplot(parent, [vl], {
|
||||
seriesDefaults:{
|
||||
renderer:$.jqplot.BarRenderer,
|
||||
rendererOptions: {fillToZero: true},
|
||||
},
|
||||
axes: {
|
||||
// Use a category axis on the x axis and use our custom ticks.
|
||||
xaxis: {
|
||||
min: 0,
|
||||
renderer: $.jqplot.CategoryAxisRenderer,
|
||||
tickRenderer: $.jqplot.CanvasAxisTickRenderer,
|
||||
tickOptions: {
|
||||
angle: -30,
|
||||
fontSize: '8pt'
|
||||
}
|
||||
},
|
||||
// Pad the y axis just a little so bars can get close to, but
|
||||
// not touch, the grid boundaries. 1.2 is the default padding.
|
||||
yaxis: {
|
||||
min: 0,
|
||||
pad: 1.05,
|
||||
tickOptions: {formatString: '%d'}
|
||||
}
|
||||
},
|
||||
seriesColors: [fillColor]
|
||||
});
|
||||
},
|
||||
|
||||
show_settings: function() {
|
||||
var d = new wn.widgets.Dialog({
|
||||
title: 'Set Company Settings',
|
||||
width: 500,
|
||||
fields: [
|
||||
{
|
||||
label:'Company',
|
||||
reqd: 1,
|
||||
fieldname:'company',
|
||||
fieldtype:'Link',
|
||||
options: 'Company'
|
||||
},
|
||||
{
|
||||
label:'Start Date',
|
||||
reqd: 1,
|
||||
fieldname:'start',
|
||||
fieldtype:'Date',
|
||||
},
|
||||
{
|
||||
label:'End Date',
|
||||
reqd: 1,
|
||||
fieldname:'end',
|
||||
fieldtype:'Date',
|
||||
},
|
||||
{
|
||||
label:'Interval',
|
||||
reqd: 1,
|
||||
fieldname:'interval',
|
||||
fieldtype:'Int'
|
||||
},
|
||||
{
|
||||
label:'Regenerate',
|
||||
fieldname:'refresh',
|
||||
fieldtype:'Button'
|
||||
}
|
||||
]
|
||||
});
|
||||
d.onshow = function() {
|
||||
d.set_values(pscript.dashboard_settings);
|
||||
}
|
||||
d.fields_dict.refresh.input.onclick = function() {
|
||||
pscript.dashboard_settings = d.get_values();
|
||||
me.refresh();
|
||||
d.hide();
|
||||
}
|
||||
d.show();
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -1,260 +0,0 @@
|
||||
dashboards = [
|
||||
{
|
||||
'type': 'account',
|
||||
'account': 'Income',
|
||||
'title': 'Income',
|
||||
'fillColor': '#90EE90'
|
||||
},
|
||||
|
||||
{
|
||||
'type': 'account',
|
||||
'account': 'Expenses',
|
||||
'title': 'Expenses',
|
||||
'fillColor': '#90EE90'
|
||||
},
|
||||
|
||||
{
|
||||
'type': 'receivables',
|
||||
'title': 'Receivables',
|
||||
'fillColor': '#FFE4B5'
|
||||
},
|
||||
|
||||
{
|
||||
'type': 'payables',
|
||||
'title': 'Payables',
|
||||
'fillColor': '#FFE4B5'
|
||||
},
|
||||
|
||||
{
|
||||
'type': 'collection',
|
||||
'title': 'Collection',
|
||||
'comment':'This info comes from the accounts your have marked as "Bank or Cash"',
|
||||
'fillColor': '#DDA0DD'
|
||||
},
|
||||
|
||||
{
|
||||
'type': 'payments',
|
||||
'title': 'Payments',
|
||||
'comment':'This info comes from the accounts your have marked as "Bank or Cash"',
|
||||
'fillColor': '#DDA0DD'
|
||||
},
|
||||
|
||||
{
|
||||
'type': 'creation',
|
||||
'doctype': 'Quotation',
|
||||
'title': 'New Quotations',
|
||||
'fillColor': '#ADD8E6'
|
||||
},
|
||||
|
||||
{
|
||||
'type': 'creation',
|
||||
'doctype': 'Sales Order',
|
||||
'title': 'New Orders',
|
||||
'fillColor': '#ADD8E6'
|
||||
}
|
||||
]
|
||||
|
||||
class DashboardWidget:
|
||||
def __init__(self, company, start, end, interval):
|
||||
from webnotes.utils import getdate
|
||||
from webnotes.model.code import get_obj
|
||||
import webnotes
|
||||
|
||||
self.company = company
|
||||
self.abbr = webnotes.conn.get_value('Company', company, 'abbr')
|
||||
self.start = getdate(start)
|
||||
self.end = getdate(end)
|
||||
|
||||
self.interval = interval
|
||||
|
||||
self.glc = get_obj('GL Control')
|
||||
self.cash_accounts = [d[0] for d in webnotes.conn.sql("""
|
||||
select name from tabAccount
|
||||
where account_type='Bank or Cash'
|
||||
and company = %s and docstatus = 0
|
||||
""", company)]
|
||||
|
||||
self.receivables_group = webnotes.conn.get_value('Company', company,'receivables_group')
|
||||
self.payables_group = webnotes.conn.get_value('Company', company,'payables_group')
|
||||
|
||||
# list of bank and cash accounts
|
||||
self.bc_list = [s[0] for s in webnotes.conn.sql("select name from tabAccount where account_type='Bank or Cash'")]
|
||||
|
||||
|
||||
def timeline(self):
|
||||
"""
|
||||
get the timeline for the dashboard
|
||||
"""
|
||||
import webnotes
|
||||
from webnotes.utils import add_days
|
||||
tl = []
|
||||
|
||||
if self.start > self.end:
|
||||
webnotes.msgprint("Start must be before end", raise_exception=1)
|
||||
|
||||
curr = self.start
|
||||
tl.append(curr)
|
||||
|
||||
while curr < self.end:
|
||||
curr = add_days(curr, self.interval, 'date')
|
||||
tl.append(curr)
|
||||
|
||||
tl.append(self.end)
|
||||
|
||||
return tl
|
||||
|
||||
def generate(self, opts):
|
||||
"""
|
||||
Generate the dasboard
|
||||
"""
|
||||
from webnotes.utils import flt
|
||||
tl = self.timeline()
|
||||
self.out = []
|
||||
|
||||
for i in range(len(tl)-1):
|
||||
self.out.append([tl[i+1].strftime('%Y-%m-%d'), flt(self.value(opts, tl[i], tl[i+1])) or 0])
|
||||
|
||||
return self.out
|
||||
|
||||
def get_account_balance(self, acc, start):
|
||||
"""
|
||||
Get as on account balance
|
||||
"""
|
||||
import webnotes
|
||||
# add abbreviation to company
|
||||
|
||||
if not acc.endswith(self.abbr):
|
||||
acc += ' - ' + self.abbr
|
||||
|
||||
# get other reqd parameters
|
||||
try:
|
||||
globals().update(webnotes.conn.sql('select debit_or_credit, lft, rgt from tabAccount where name=%s', acc, as_dict=1)[0])
|
||||
except Exception,e:
|
||||
webnotes.msgprint('Wrongly defined account: ' + acc)
|
||||
print acc
|
||||
raise e
|
||||
|
||||
return self.glc.get_as_on_balance(acc, self.get_fiscal_year(start), start, debit_or_credit, lft, rgt)
|
||||
|
||||
def get_fiscal_year(self, dt):
|
||||
"""
|
||||
get fiscal year from date
|
||||
"""
|
||||
import webnotes
|
||||
return webnotes.conn.sql("""
|
||||
select name from `tabFiscal Year`
|
||||
where year_start_date <= %s and
|
||||
DATE_ADD(year_start_date, INTERVAL 1 YEAR) >= %s
|
||||
""", (dt, dt))[0][0]
|
||||
|
||||
def get_creation_trend(self, doctype, start, end):
|
||||
"""
|
||||
Get creation # of creations in period
|
||||
"""
|
||||
import webnotes
|
||||
return int(webnotes.conn.sql("""
|
||||
select count(*) from `tab%s` where creation between %s and %s and docstatus=1
|
||||
""" % (doctype, '%s','%s'), (start, end))[0][0])
|
||||
|
||||
def get_account_amt(self, acc, start, end, debit_or_credit):
|
||||
"""
|
||||
Get debit, credit over a period
|
||||
"""
|
||||
import webnotes
|
||||
# add abbreviation to company
|
||||
|
||||
if not acc.endswith(self.abbr):
|
||||
acc += ' - ' + self.abbr
|
||||
|
||||
ret = webnotes.conn.sql("""
|
||||
select ifnull(sum(ifnull(t1.debit,0)),0), ifnull(sum(ifnull(t1.credit,0)),0)
|
||||
from `tabGL Entry` t1, tabAccount t2
|
||||
where t1.account = t2.name
|
||||
and t2.is_pl_account = 'Yes'
|
||||
and t2.debit_or_credit=%s
|
||||
and ifnull(t1.is_cancelled, 'No')='No'
|
||||
and t1.posting_date between %s and %s
|
||||
""", (debit_or_credit, start, end))[0]
|
||||
|
||||
return debit_or_credit=='Credit' and float(ret[1]-ret[0]) or float(ret[0]-ret[1])
|
||||
|
||||
def get_bank_amt(self, debit_or_credit, master_type, start, end):
|
||||
"""
|
||||
Get collection (reduction in receivables over a period)
|
||||
"""
|
||||
import webnotes
|
||||
|
||||
reg = '('+'|'.join(self.bc_list) + ')'
|
||||
|
||||
return webnotes.conn.sql("""
|
||||
select sum(t1.%s)
|
||||
from `tabGL Entry` t1, tabAccount t2
|
||||
where t1.account = t2.name
|
||||
and t2.master_type='%s'
|
||||
and t1.%s > 0
|
||||
and t1.against REGEXP '%s'
|
||||
and ifnull(t1.is_cancelled, 'No')='No'
|
||||
and t1.posting_date between '%s' and '%s'
|
||||
""" % (debit_or_credit, master_type, debit_or_credit, reg, start, end))[0][0]
|
||||
|
||||
|
||||
def value(self, opts, start, end):
|
||||
"""
|
||||
Value of the series on a particular date
|
||||
"""
|
||||
import webnotes
|
||||
if opts['type']=='account':
|
||||
debit_or_credit = 'Debit'
|
||||
if opts['account']=='Income':
|
||||
debit_or_credit = 'Credit'
|
||||
|
||||
return self.get_account_amt(opts['account'], start, end, debit_or_credit)
|
||||
|
||||
elif opts['type']=='receivables':
|
||||
return self.get_account_balance(self.receivables_group, end)[2]
|
||||
|
||||
elif opts['type']=='payables':
|
||||
return self.get_account_balance(self.payables_group, end)[2]
|
||||
|
||||
elif opts['type']=='collection':
|
||||
return self.get_bank_amt('credit', 'Customer', start, end)
|
||||
|
||||
elif opts['type']=='payments':
|
||||
return self.get_bank_amt('debit', 'Supplier', start, end)
|
||||
|
||||
elif opts['type']=='creation':
|
||||
return self.get_creation_trend(opts['doctype'], start, end)
|
||||
|
||||
|
||||
def load_dashboard(args):
|
||||
"""
|
||||
Get dashboard based on
|
||||
1. Company (default company)
|
||||
2. Start Date (last 3 months)
|
||||
3. End Date (today)
|
||||
4. Interval (7 days)
|
||||
"""
|
||||
dl = []
|
||||
import json
|
||||
args = json.loads(args)
|
||||
dw = DashboardWidget(args['company'], args['start'], args['end'], int(args['interval']))
|
||||
|
||||
# render the dashboards
|
||||
for d in dashboards:
|
||||
dl.append([d, dw.generate(d)])
|
||||
|
||||
return dl
|
||||
|
||||
if __name__=='__main__':
|
||||
import sys
|
||||
sys.path.append('/var/www/webnotes/wnframework/cgi-bin')
|
||||
from webnotes.db import Database
|
||||
import webnotes
|
||||
webnotes.conn = Database(use_default=1)
|
||||
webnotes.session = {'user':'Administrator'}
|
||||
print load_dashboard("""{
|
||||
"company": "My Test",
|
||||
"start": "2011-05-01",
|
||||
"end": "2011-08-01",
|
||||
"interval": "7"
|
||||
}""")
|
||||
@@ -1,49 +0,0 @@
|
||||
# Page, dashboard
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2011-08-25 16:22:44',
|
||||
'docstatus': 0,
|
||||
'modified': '2011-08-25 16:22:54',
|
||||
'modified_by': 'Administrator',
|
||||
'owner': 'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all Page
|
||||
{
|
||||
'category': 'Standard',
|
||||
'doctype': 'Page',
|
||||
'module': 'Home',
|
||||
'name': '__common__',
|
||||
'page_name': 'Dashboard',
|
||||
'standard': 'Yes'
|
||||
},
|
||||
|
||||
# These values are common for all Page Role
|
||||
{
|
||||
'doctype': 'Page Role',
|
||||
'name': '__common__',
|
||||
'parent': 'dashboard',
|
||||
'parentfield': 'roles',
|
||||
'parenttype': 'Page'
|
||||
},
|
||||
|
||||
# Page, dashboard
|
||||
{
|
||||
'doctype': 'Page',
|
||||
'name': 'dashboard'
|
||||
},
|
||||
|
||||
# Page Role
|
||||
{
|
||||
'doctype': 'Page Role',
|
||||
'role': 'System Manager'
|
||||
},
|
||||
|
||||
# Page Role
|
||||
{
|
||||
'doctype': 'Page Role',
|
||||
'role': 'Accounts Manager'
|
||||
}
|
||||
]
|
||||
BIN
home/page/event_updates/.DS_Store
vendored
BIN
home/page/event_updates/.DS_Store
vendored
Binary file not shown.
@@ -1,62 +0,0 @@
|
||||
div.home-status {
|
||||
margin: 7px;
|
||||
padding: 5px;
|
||||
color: #666;
|
||||
}
|
||||
|
||||
span.home-status-link {
|
||||
cursor: pointer;
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
span.home-status-unread {
|
||||
padding: 2px 3px;
|
||||
font-size: 11px;
|
||||
color: #FFF;
|
||||
background-color: RED;
|
||||
}
|
||||
|
||||
div.setup-wizard {
|
||||
display: none;
|
||||
margin: 13px 0px;
|
||||
background-color: #FED;
|
||||
padding: 13px;
|
||||
}
|
||||
|
||||
div.setup-wizard .header {
|
||||
font-size: 12px;
|
||||
font-weight: bold;
|
||||
color: #322;
|
||||
margin-bottom: 7px;
|
||||
}
|
||||
|
||||
|
||||
div.setup-wizard .percent-outer {
|
||||
height: 17px;
|
||||
background-color: #FFF;
|
||||
border: 2px solid #322;
|
||||
}
|
||||
|
||||
div.setup-wizard .percent-inner {
|
||||
height: 17px;
|
||||
background-color: GREEN;
|
||||
}
|
||||
|
||||
div.setup-wizard .suggestion {
|
||||
margin: 7px 0px;
|
||||
color: #322;
|
||||
}
|
||||
|
||||
div.setup-wizard .prev-next {
|
||||
height: 13px;
|
||||
}
|
||||
|
||||
div.setup-wizard .prev-next span {
|
||||
display: none;
|
||||
float: right;
|
||||
margin-left: 13px;
|
||||
color: #877;
|
||||
font-size: 11px;
|
||||
}
|
||||
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
<div id="updates_div"></div>
|
||||
@@ -1,764 +0,0 @@
|
||||
pscript['onload_Event Updates'] = function() {
|
||||
if(user=='Guest') {
|
||||
loadpage('Login Page');
|
||||
return;
|
||||
}
|
||||
|
||||
pscript.home_make_body();
|
||||
pscript.home_make_status();
|
||||
pscript.home_pre_process();
|
||||
pscript.home_make_widgets();
|
||||
}
|
||||
|
||||
// ==================================
|
||||
|
||||
pscript.home_make_body = function() {
|
||||
var wrapper = page_body.pages['Event Updates'];
|
||||
|
||||
// body
|
||||
wrapper.main_tab = make_table(wrapper,1,2,'100%',['70%','30%']);
|
||||
$y(wrapper.main_tab, {tableLayout:'fixed'});
|
||||
|
||||
wrapper.body = $a($td(wrapper.main_tab, 0, 0), 'div', 'layout_wrapper');
|
||||
|
||||
wrapper.head = $a(wrapper.body, 'div');
|
||||
|
||||
wrapper.banner_area = $a(wrapper.head, 'div');
|
||||
|
||||
wrapper.setup_wizard_area = $a(wrapper.body, 'div', 'setup-wizard');
|
||||
}
|
||||
|
||||
// ==================================
|
||||
|
||||
pscript.home_pre_process = function(wrapper) {
|
||||
var wrapper = page_body.pages['Event Updates'];
|
||||
var cp = locals['Control Panel']['Control Panel'];
|
||||
|
||||
// banner
|
||||
if(cp.client_name) {
|
||||
var banner = $a(wrapper.banner_area, 'div', '', {paddingBottom:'4px'})
|
||||
banner.innerHTML = cp.client_name;
|
||||
}
|
||||
|
||||
// complete registration
|
||||
if(in_list(user_roles,'System Manager')) { pscript.complete_registration(); }
|
||||
}
|
||||
|
||||
// Widgets
|
||||
// ==================================
|
||||
|
||||
pscript.home_make_widgets = function() {
|
||||
var wrapper = page_body.pages['Event Updates'];
|
||||
var cell = $td(wrapper.main_tab, 0, 1);
|
||||
|
||||
// sidebar
|
||||
sidebar = new wn.widgets.PageSidebar(cell, {
|
||||
sections:[
|
||||
{
|
||||
title: 'Calendar',
|
||||
display: function() { return !has_common(user_roles, ['Guest','Customer','Vendor'])},
|
||||
render: function(wrapper) {
|
||||
new HomeCalendar(new HomeWidget(wrapper, 'Calendar', 'Event'), wrapper);
|
||||
}
|
||||
},
|
||||
|
||||
{
|
||||
title: 'To Do',
|
||||
display: function() { return !has_common(user_roles, ['Guest','Customer','Vendor'])},
|
||||
render: function(wrapper) {
|
||||
new HomeToDo(new HomeWidget(wrapper, 'To Do', 'Item'));
|
||||
}
|
||||
},
|
||||
|
||||
{
|
||||
title: 'Online Users',
|
||||
display: function() { return !has_common(user_roles, ['Guest','Customer','Vendor'])},
|
||||
render: function(wrapper) {
|
||||
pscript.online_users_obj = new OnlineUsers(wrapper);
|
||||
}
|
||||
}
|
||||
]
|
||||
})
|
||||
sidebar.refresh()
|
||||
|
||||
/*$y(cell,{padding:'0px 8px'});
|
||||
|
||||
new HomeCalendar(new HomeWidget(cell, 'Calendar', 'Event'));
|
||||
|
||||
|
||||
new HomeToDo(new HomeWidget(cell, 'To Do', 'Item'));*/
|
||||
|
||||
new FeedList(wrapper.body);
|
||||
}
|
||||
|
||||
OnlineUsers = function(wrapper) {
|
||||
var me = this;
|
||||
this.wrapper = wrapper;
|
||||
|
||||
this.my_company_link = function() {
|
||||
$a($a(wrapper, 'div', '', {marginBottom:'7px'}), 'span', 'link_type',
|
||||
{color:'#777', 'color:hover':'#FFF', fontSize:'11px'},
|
||||
'See all users', function() {loadpage('My Company'); });
|
||||
}
|
||||
|
||||
this.render = function(online_users) {
|
||||
me.my_company_link();
|
||||
|
||||
if(online_users.length) {
|
||||
var max = online_users.length; max = (max > 10 ? 10 : max)
|
||||
for(var i=0; i<max; i++) {
|
||||
new OneOnlineUser(me.wrapper, online_users[i]);
|
||||
}
|
||||
} else {
|
||||
$a(wrapper, 'div', '', {'color':'#888'}, 'No user online!')
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
OneOnlineUser = function(wrapper, det) {
|
||||
var name = cstr(det[1]) + ' ' + cstr(det[2]);
|
||||
if(det[1]==user) name = 'You'
|
||||
var div = $a(wrapper, 'div', '', {padding:'3px 0px'});
|
||||
$a(div, 'div', '', {width:'7px', height:'7px', cssFloat:'left', margin:'5px', backgroundColor:'green'});
|
||||
$a(div, 'div', '', {marginLeft:'3px'}, name);
|
||||
}
|
||||
|
||||
HomeWidget = function(parent, heading, item) {
|
||||
var me = this; this.item = item;
|
||||
|
||||
this.wrapper = $a(parent, 'div');
|
||||
|
||||
|
||||
// body
|
||||
this.body = $a(this.wrapper,'div','',{paddingBottom:'16px'});
|
||||
this.footer = $a(this.wrapper,'div');
|
||||
|
||||
// add button
|
||||
this.add_btn = $btn(this.footer,'+ Add ' + item,function(){me.add()});
|
||||
|
||||
// refresh
|
||||
this.refresh_btn = $ln(this.footer,'Refresh',function() { me.refresh(); },{fontSize:'11px',marginLeft:'7px',color:'#888'});
|
||||
}
|
||||
|
||||
HomeWidget.prototype.refresh = function() {
|
||||
var me = this;
|
||||
$di(this.working_img);
|
||||
|
||||
var callback = function(r,rt) {
|
||||
$dh(me.working_img);
|
||||
me.body.innerHTML = '';
|
||||
|
||||
// prepare (for calendar?)
|
||||
if(me.decorator.setup_body) me.decorator.setup_body();
|
||||
|
||||
for(var i=0;i<r.message.length;i++) {
|
||||
new HomeWidgetItem(me, r.message[i]);
|
||||
}
|
||||
if(!r.message.length) {
|
||||
$a(me.body,'div','',{color:'#777'}, me.no_items_message);
|
||||
}
|
||||
}
|
||||
$c_obj('Home Control',this.get_list_method,'',callback);
|
||||
}
|
||||
|
||||
HomeWidget.prototype.make_dialog = function() {
|
||||
var me = this;
|
||||
if(!this.dialog) {
|
||||
this.dialog = new wn.widgets.Dialog();
|
||||
this.dialog.make({
|
||||
width: 480,
|
||||
title: 'New ' + this.item,
|
||||
fields:this.dialog_fields
|
||||
});
|
||||
|
||||
this.dialog.fields_dict.save.input.onclick = function() {
|
||||
this.set_working();
|
||||
me.decorator.save(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
HomeWidget.prototype.add = function() {
|
||||
this.make_dialog();
|
||||
this.decorator.clear_dialog();
|
||||
this.dialog.show();
|
||||
}
|
||||
|
||||
// Item
|
||||
// --------
|
||||
|
||||
HomeWidgetItem = function(widget, det) {
|
||||
var me = this; this.det = det; this.widget = widget;
|
||||
this.widget = widget; this.det = det;
|
||||
|
||||
// parent
|
||||
if(widget.decorator.get_item_parent) parent = widget.decorator.get_item_parent(det);
|
||||
else parent = widget.body;
|
||||
|
||||
if(!parent) return;
|
||||
|
||||
// wrapper
|
||||
this.wrapper = $a(parent, 'div');
|
||||
this.tab = make_table(this.wrapper, 1, 3, '100%', ['90%', '5%', '5%'],{paddingRight:'4px'});
|
||||
|
||||
// buttons
|
||||
this.edit_btn = $a($td(this.tab,0,1),'div','wn-icon ' + 'ic-doc_edit', {cursor:'pointer'});
|
||||
this.edit_btn.onclick = function() { me.edit(); }
|
||||
|
||||
this.del_btn = $a($td(this.tab,0,2),'div','wn-icon ' + 'ic-trash', {cursor:'pointer'});
|
||||
this.del_btn.onclick = function() { me.delete_item(); }
|
||||
|
||||
widget.decorator.render_item(this, det);
|
||||
}
|
||||
|
||||
HomeWidgetItem.prototype.edit = function() {
|
||||
this.widget.make_dialog();
|
||||
this.widget.decorator.set_dialog_values(this.det);
|
||||
this.widget.dialog.show();
|
||||
}
|
||||
|
||||
HomeWidgetItem.prototype.delete_item = function() {
|
||||
var me = this;
|
||||
this.wrapper.innerHTML = '<span style="color:#888">Deleting...</span>';
|
||||
var callback = function(r,rt) {
|
||||
$(me.wrapper).slideUp();
|
||||
}
|
||||
$c_obj('Home Control',this.widget.delete_method, this.widget.get_item_id(this.det) ,callback);
|
||||
|
||||
}
|
||||
|
||||
// Calendar
|
||||
// ===========================
|
||||
|
||||
HomeCalendar = function(widget, wrapper) {
|
||||
// calendar link
|
||||
$ln(widget.footer,'Full Calendar',function() { loadpage('_calendar'); },{marginLeft:'7px', fontSize:'11px', color:'#888'})
|
||||
|
||||
this.widget = widget;
|
||||
|
||||
// methods
|
||||
this.widget.get_list_method = 'get_events_list'
|
||||
this.widget.delete_method = 'delete_event';
|
||||
this.widget.no_items_message = 'You have no events in the next 7 days';
|
||||
this.widget.get_item_id = function(det) { return det.name; }
|
||||
|
||||
this.widget.decorator = this;
|
||||
|
||||
var hl = [];
|
||||
for(var i=0; i<24; i++) {
|
||||
hl.push(((i+8) % 24) + ':00');
|
||||
}
|
||||
|
||||
this.widget.dialog_fields = [
|
||||
{fieldtype:'Date', fieldname:'event_date', label:'Event Date', reqd:1},
|
||||
{fieldtype:'Time', fieldname:'event_hour', label:'Event Time', reqd:1},
|
||||
{fieldtype:'Text', fieldname:'description', label:'Description', reqd:1},
|
||||
{fieldtype:'Button', fieldname:'save', label:'Save'}
|
||||
];
|
||||
|
||||
this.widget.refresh();
|
||||
}
|
||||
|
||||
// create calendar grid
|
||||
// --------------------
|
||||
HomeCalendar.prototype.setup_body = function() {
|
||||
var w = this.widget;
|
||||
w.date_blocks = {};
|
||||
for(var i=0; i<7; i++) {
|
||||
var dt = dateutil.obj_to_str(dateutil.add_days(new Date(),i));
|
||||
var div = $a(w.body, 'div', '', {padding:'4px 0px', borderBottom:'1px solid #AAA',display:'none'});
|
||||
div.head = $a(div, 'div', '', {fontWeight:'bold', paddingBottom:'4px'});
|
||||
div.head.innerHTML = (i==0 ? 'Today' : (i==1 ? 'Tomorrow' : dateutil.str_to_user(dt)))
|
||||
w.date_blocks[dt] = div;
|
||||
}
|
||||
}
|
||||
|
||||
HomeCalendar.prototype.get_item_parent = function(det) {
|
||||
var d = this.widget.date_blocks[det.event_date]; $ds(d);
|
||||
return d;
|
||||
}
|
||||
|
||||
HomeCalendar.prototype.render_item = function(item, det) {
|
||||
var tab = make_table($td(item.tab, 0, 0), 1, 2, '100%', ['48px', null], {padding:'2px', lineHeight:'1.5em'});
|
||||
$y(tab, {tableLayout:'fixed'});
|
||||
|
||||
$td(tab, 0, 0).innerHTML = '<span style="color:#888">' + det.event_hour + ':</span> ';
|
||||
$a($td(tab, 0, 1), 'span', 'social', {}, replace_newlines(det.description));
|
||||
|
||||
if(det.ref_type && det.ref_name && det.ref_name != 'None') {
|
||||
var span=$a($a($td(tab, 0, 1),'div'),'span','link_type');
|
||||
span.innerHTML = det.ref_name; span.dt = det.ref_type;
|
||||
span.onclick = function() { loaddoc(this.dt, this.innerHTML); }
|
||||
}
|
||||
}
|
||||
|
||||
HomeCalendar.prototype.clear_dialog = function() {
|
||||
this.set_dialog_values({event_date:get_today(), event_hour:'8:00', description:''});
|
||||
}
|
||||
|
||||
HomeCalendar.prototype.set_dialog_values = function(det) {
|
||||
var d = this.widget.dialog;
|
||||
d.set_values(det);
|
||||
d.det = det;
|
||||
}
|
||||
|
||||
HomeCalendar.prototype.save = function(btn) {
|
||||
var d = this.widget.dialog;
|
||||
var me = this;
|
||||
var det = d.get_values();
|
||||
|
||||
if(!det) {
|
||||
btn.done_working();
|
||||
return;
|
||||
}
|
||||
|
||||
det.name = d.det.name;
|
||||
det.owner = user;
|
||||
if(!det.event_type)
|
||||
det.event_type = 'Private';
|
||||
|
||||
var callback = function(r,rt) {
|
||||
btn.done_working();
|
||||
me.widget.dialog.hide();
|
||||
me.widget.refresh();
|
||||
}
|
||||
$c_obj('Home Control','edit_event',JSON.stringify(det),callback);
|
||||
}
|
||||
|
||||
// Todo
|
||||
// ===========================
|
||||
|
||||
HomeToDo = function(widget) {
|
||||
this.widget = widget;
|
||||
|
||||
// methods
|
||||
this.widget.get_list_method = 'get_todo_list';
|
||||
this.widget.delete_method = 'remove_todo_item';
|
||||
this.widget.no_items_message = 'Nothing to do?';
|
||||
this.widget.get_item_id = function(det) { return det[0]; }
|
||||
|
||||
this.widget.decorator = this;
|
||||
|
||||
this.widget.dialog_fields = [
|
||||
{fieldtype:'Date', fieldname:'date', label:'Event Date', reqd:1},
|
||||
{fieldtype:'Text', fieldname:'description', label:'Description', reqd:1},
|
||||
{fieldtype:'Check', fieldname:'checked', label:'Completed'},
|
||||
{fieldtype:'Select', fieldname:'priority', label:'Priority', reqd:1, 'options':['Medium','High','Low'].join('\n')},
|
||||
{fieldtype:'Button', fieldname:'save', label:'Save'}
|
||||
];
|
||||
|
||||
this.widget.refresh();
|
||||
}
|
||||
|
||||
HomeToDo.prototype.render_item = function(item, det) {
|
||||
|
||||
// priority tag
|
||||
var tab = make_table($td(item.tab, 0, 0), 1, 2, '100%', ['48px', null], {padding:'2px'});
|
||||
$y(tab, {tableLayout:'fixed'});
|
||||
|
||||
var span = $a($td(tab, 0, 0), 'span', '', {padding:'2px',color:'#FFF',fontSize:'10px'
|
||||
,backgroundColor:(det[3]=='Low' ? '#888' : (det[3]=='High' ? '#EDA857' : '#687FD3'))});
|
||||
|
||||
$(span).css('-moz-border-radius','3px').css('-webkit-border-radius','3px');
|
||||
span.innerHTML = det[3];
|
||||
|
||||
// text
|
||||
var span = $a($td(tab, 0, 1), 'span', 'social', {lineHeight:'1.5em'}, replace_newlines(det[1]));
|
||||
if(det[4]) $y(span,{textDecoration:'line-through'});
|
||||
|
||||
// if expired & open, then in red
|
||||
if(!det[4] && dateutil.str_to_obj(det[2]) < new Date()) {
|
||||
$y(span,{color:'RED'});
|
||||
$a($td(tab, 0, 1), 'div', '', {fontSize:'10px', color:'#666'}, dateutil.str_to_user(det[2]) + ' (Overdue)');
|
||||
} else {
|
||||
$a($td(tab, 0, 1), 'div', '', {fontSize:'10px', color:'#666'}, dateutil.str_to_user(det[2]));
|
||||
}
|
||||
}
|
||||
|
||||
HomeToDo.prototype.clear_dialog = function() {
|
||||
this.set_dialog_values(['','',get_today(),'Medium',0]);
|
||||
}
|
||||
|
||||
HomeToDo.prototype.set_dialog_values = function(det) {
|
||||
var d = this.widget.dialog;
|
||||
d.set_values({
|
||||
date: det[2],
|
||||
priority: det[3],
|
||||
description: det[1],
|
||||
checked: det[4]
|
||||
});
|
||||
d.det = det;
|
||||
}
|
||||
|
||||
HomeToDo.prototype.save = function(btn) {
|
||||
var d = this.widget.dialog;
|
||||
var me = this;
|
||||
|
||||
var det = d.get_values()
|
||||
if(!det) {
|
||||
btn.done_working();
|
||||
return;
|
||||
}
|
||||
|
||||
det.name = d.det ? d.det[0] : '';
|
||||
|
||||
var callback = function(r,rt) {
|
||||
btn.done_working();
|
||||
me.widget.dialog.hide();
|
||||
me.widget.refresh();
|
||||
}
|
||||
$c_obj('Home Control','add_todo_item',JSON.stringify(det),callback);
|
||||
}
|
||||
|
||||
// Feed
|
||||
// ==================================
|
||||
|
||||
|
||||
FeedList = function(parent) {
|
||||
// settings
|
||||
this.auto_feed_off = cint(sys_defaults.auto_feed_off);
|
||||
|
||||
this.wrapper = $a(parent, 'div');
|
||||
this.make_head();
|
||||
this.make_list();
|
||||
this.list.run();
|
||||
}
|
||||
|
||||
FeedList.prototype.make_head = function() {
|
||||
var me = this;
|
||||
this.head = $a(this.wrapper, 'div', '', {marginBottom:'8px'});
|
||||
|
||||
// head
|
||||
|
||||
$a(this.head,'h1','', {display:'inline'}, 'Home');
|
||||
$a(this.head,'span','link_type', {marginLeft:'7px'}, 'help', function() {
|
||||
msgprint('<b>What appears here?</b> This is where you get updates of everything you are permitted to follow')
|
||||
})
|
||||
|
||||
// refresh
|
||||
$a(this.head,'span','link_type',
|
||||
{cursor:'pointer', marginLeft:'7px', fontSize:'11px'}, 'refresh',
|
||||
function() { me.run(); }
|
||||
);
|
||||
|
||||
if(has_common(user_roles, ['System Manager','Accounts Manager'])) {
|
||||
$btn(this.head, 'Dashboard', function() {loadpage('dashboard'); }, {marginLeft:'7px'})
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
FeedList.prototype.run = function() {
|
||||
this.prev_date = null;
|
||||
this.list.run();
|
||||
}
|
||||
|
||||
FeedList.prototype.make_list = function() {
|
||||
this.list_area = $a(this.wrapper,'div')
|
||||
this.no_result = $a(this.wrapper, 'div','help_box',{display:'none'},'Nothing to show yet. Your feed will be updated as you start your activities')
|
||||
|
||||
var l = new Listing('Feed List',1);
|
||||
var me = this;
|
||||
|
||||
// style
|
||||
l.colwidths = ['100%']; l.page_len = 20;
|
||||
l.opts.cell_style = {padding:'0px'};
|
||||
l.opts.hide_rec_label = 1;
|
||||
|
||||
// build query
|
||||
l.get_query = function(){
|
||||
this.query = repl('select \
|
||||
distinct t1.name, t1.doc_type, t1.doc_name, t1.subject, t1.modified_by, \
|
||||
concat(ifnull(t2.first_name,""), " ", ifnull(t2.last_name,"")), t1.modified, t1.color \
|
||||
from tabFeed t1, tabProfile t2, tabUserRole t3, tabDocPerm t4 \
|
||||
where t1.doc_type = t4.parent \
|
||||
and t2.name = t1.owner \
|
||||
and t3.parent = "%(user)s" \
|
||||
and t4.role = t3.role \
|
||||
and ifnull(t4.`read`,0) = 1 \
|
||||
order by t1.modified desc', {user:user})
|
||||
this.query_max = ''
|
||||
}
|
||||
|
||||
// render list ui
|
||||
l.show_cell = function(cell,ri,ci,d){ me.render_feed(cell,ri,ci,d); }
|
||||
|
||||
// onrun
|
||||
l.onrun = function(){ $(me.wrapper).fadeIn(); if(me.after_run) me.after_run(); }
|
||||
|
||||
// make
|
||||
l.make(this.list_area);
|
||||
$dh(l.btn_area);
|
||||
|
||||
this.list = l;
|
||||
}
|
||||
|
||||
FeedList.prototype.after_run = function() {
|
||||
this.list.has_data() ? $dh(this.no_result) : $ds(this.no_result)
|
||||
}
|
||||
|
||||
FeedList.prototype.render_feed = function(cell,ri,ci,d) {
|
||||
new FeedItem(cell, d[ri], this);
|
||||
}
|
||||
|
||||
// Item
|
||||
// -------------------------------
|
||||
|
||||
FeedItem = function(cell, det, feedlist) {
|
||||
var me = this;
|
||||
|
||||
this.det = det; this.feedlist = feedlist;
|
||||
this.wrapper = $a(cell,'div','',{paddingBottom:'4px'});
|
||||
this.head = $a(this.wrapper,'div');
|
||||
|
||||
this.tab = make_table(this.wrapper, 1, 2, '100%', [(100/7)+'%', (600/7)+'%']);
|
||||
$y(this.tab,{tableLayout:'fixed'})
|
||||
|
||||
// image
|
||||
$y($td(this.tab,0,0),{textAlign:'right',paddingRight:'4px'});
|
||||
|
||||
// text
|
||||
this.text_area = $a($td(this.tab,0,1), 'div');
|
||||
this.render_references(this.text_area, det);
|
||||
|
||||
this.render_tag(det);
|
||||
|
||||
// add day separator
|
||||
this.add_day_sep(det);
|
||||
}
|
||||
|
||||
// Day separator
|
||||
// -------------------------------------------------
|
||||
|
||||
FeedItem.prototype.add_day_sep = function(det) {
|
||||
var me = this;
|
||||
var prev_date = det[6].split(' ')[0];
|
||||
|
||||
var make_div = function() {
|
||||
var div = $a(me.head, 'div', '',
|
||||
{borderBottom:'1px solid #888', margin:'8px 0px', padding:'2px 0px', color:'#888', fontSize:'11px'});
|
||||
div.innerHTML = comment_when(det[6], 1);
|
||||
|
||||
// today?
|
||||
if(prev_date==get_today()) {
|
||||
div.innerHTML = '';
|
||||
span = $a(div, 'span', '', {padding:'2px', color:'#000', fontWeight:'bold'});
|
||||
span.innerHTML = 'Today';
|
||||
}
|
||||
}
|
||||
|
||||
if(this.feedlist.prev_date && this.feedlist.prev_date != prev_date) { make_div(); }
|
||||
if(!this.feedlist.prev_date) { make_div(); }
|
||||
this.feedlist.prev_date = prev_date;
|
||||
}
|
||||
|
||||
// Tag
|
||||
// -------------------------------------------------
|
||||
|
||||
FeedItem.prototype.render_tag = function(det) {
|
||||
tag = $a($td(this.tab,0,0), 'div', '',
|
||||
{color:'#FFF', padding:'3px', textAlign:'right', fontSize:'11px', whiteSpace:'nowrap', overflow:'hidden', cursor:'pointer'});
|
||||
$br(tag,'3px');
|
||||
$y(tag, {backgroundColor:(det[7] ? det[7] : '#273')});
|
||||
tag.innerHTML = get_doctype_label(det[1]);
|
||||
tag.dt = det[1]
|
||||
tag.onclick = function() { loaddocbrowser(this.dt); }
|
||||
}
|
||||
|
||||
FeedItem.prototype.render_references = function(div, det) {
|
||||
// name
|
||||
div.tab = make_table(div, 1, 2, '100%', [null, '15%'])
|
||||
//div.innerHTML = '<b>' + (strip(det[11]) ? det[11] : det[2]) + ' (' + cint(det[12]) + '): </b> has ' + det[7] + ' ';
|
||||
|
||||
var dt = det[1]; var dn = det[2]
|
||||
|
||||
// link
|
||||
var allow = in_list(profile.can_read, dt);
|
||||
var span = $a($td(div.tab,0,0), 'span', (allow ? 'link_type': ''), null, det[2]);
|
||||
span.dt = dt; span.dn = dn;
|
||||
if(allow) span.onclick = function() { loaddoc(this.dt, this.dn); }
|
||||
|
||||
// subject
|
||||
if(det[3]) {
|
||||
$a($td(div.tab,0,0), 'span', '', {marginLeft:'7px', color:'#444'}, det[3]);
|
||||
}
|
||||
|
||||
// by
|
||||
$y($td(div.tab,0,1), {fontSize:'11px'}).innerHTML = (strip(det[5]) ? det[5] : det[4]);
|
||||
}
|
||||
|
||||
HomeStatusBar = function() {
|
||||
var me = this;
|
||||
var parent = page_body.pages['Event Updates'];
|
||||
this.wrapper = $a($td(parent.main_tab, 0, 1), 'div', 'home-status', {}, 'Loading...');
|
||||
$br(this.wrapper, '3px');
|
||||
|
||||
this.render = function(r) {
|
||||
this.wrapper.innerHTML = '';
|
||||
this.span = $a(this.wrapper, 'span', 'link_type', {fontWeight:'bold'});
|
||||
this.span.onclick = function() { loadpage('My Company') }
|
||||
|
||||
if(r.unread_messages) {
|
||||
this.span.innerHTML = '<span class="home-status-unread">' + r.unread_messages + '</span> unread';
|
||||
} else {
|
||||
this.span.innerHTML = 'Team / Messages';
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
pscript.home_make_status = function() {
|
||||
var home_status_bar = new HomeStatusBar()
|
||||
var wrapper = page_body.pages['Event Updates'];
|
||||
|
||||
// get values
|
||||
$c_page('home', 'event_updates', 'get_status_details', user,
|
||||
function(r,rt) {
|
||||
home_status_bar.render(r.message);
|
||||
|
||||
// render online users
|
||||
pscript.online_users_obj.render(r.message.online_users);
|
||||
pscript.online_users = r.message.online_users;
|
||||
|
||||
// setup wizard
|
||||
if(r.message.setup_status) {
|
||||
new SetupWizard(r.message.setup_status)
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
// complete my company registration
|
||||
// --------------------------------
|
||||
pscript.complete_registration = function()
|
||||
{
|
||||
var reg_callback = function(r, rt){
|
||||
if(r.message == 'No'){
|
||||
var d = new Dialog(400, 200, "Please Complete Your Registration");
|
||||
if(user != 'Administrator'){
|
||||
d.no_cancel(); // Hide close image
|
||||
$dh(page_body.wntoolbar.wrapper);
|
||||
}
|
||||
$($a(d.body,'div','', {margin:'8px', color:'#888'})).html('<b>Company Name : </b>'+locals['Control Panel']['Control Panel'].company_name);
|
||||
|
||||
d.make_body(
|
||||
[
|
||||
['Data','Company Abbreviation'],
|
||||
['Select','Fiscal Year Start Date'],
|
||||
['Select','Default Currency'],
|
||||
['Button','Save'],
|
||||
]);
|
||||
|
||||
//d.widgets['Save'].disabled = true; // disable Save button
|
||||
pscript.make_dialog_field(d);
|
||||
|
||||
// submit details
|
||||
d.widgets['Save'].onclick = function()
|
||||
{
|
||||
d.widgets['Save'].set_working();
|
||||
|
||||
flag = pscript.validate_fields(d);
|
||||
if(flag)
|
||||
{
|
||||
var args = [
|
||||
locals['Control Panel']['Control Panel'].company_name,
|
||||
d.widgets['Company Abbreviation'].value,
|
||||
d.widgets['Fiscal Year Start Date'].value,
|
||||
d.widgets['Default Currency'].value
|
||||
];
|
||||
|
||||
$c_obj('Setup Control','setup_account',JSON.stringify(args),function(r, rt){
|
||||
sys_defaults = r.message;
|
||||
d.hide();
|
||||
$ds(page_body.wntoolbar.wrapper);
|
||||
});
|
||||
}
|
||||
}
|
||||
d.show();
|
||||
}
|
||||
}
|
||||
$c_obj('Home Control','registration_complete','',reg_callback);
|
||||
}
|
||||
|
||||
// make dialog fields
|
||||
// ------------------
|
||||
pscript.make_dialog_field = function(d)
|
||||
{
|
||||
// fiscal year format
|
||||
fisc_format = d.widgets['Fiscal Year Start Date'];
|
||||
add_sel_options(fisc_format, ['', '1st Jan', '1st Apr', '1st Jul', '1st Oct']);
|
||||
|
||||
// default currency
|
||||
currency_list = ['', 'AED', 'AFN', 'ALL', 'AMD', 'ANG', 'AOA', 'ARS', 'AUD', 'AZN', 'BAM', 'BBD', 'BDT', 'BGN', 'BHD', 'BIF', 'BMD', 'BND', 'BOB', 'BRL', 'BSD', 'BTN', 'BYR', 'BZD', 'CAD', 'CDF', 'CFA', 'CFP', 'CHF', 'CLP', 'CNY', 'COP', 'CRC', 'CUC', 'CZK', 'DJF', 'DKK', 'DOP', 'DZD', 'EEK', 'EGP', 'ERN', 'ETB', 'EUR', 'EURO', 'FJD', 'FKP', 'FMG', 'GBP', 'GEL', 'GHS', 'GIP', 'GMD', 'GNF', 'GQE', 'GTQ', 'GYD', 'HKD', 'HNL', 'HRK', 'HTG', 'HUF', 'IDR', 'ILS', 'INR', 'IQD', 'IRR', 'ISK', 'JMD', 'JOD', 'JPY', 'KES', 'KGS', 'KHR', 'KMF', 'KPW', 'KRW', 'KWD', 'KYD', 'KZT', 'LAK', 'LBP', 'LKR', 'LRD', 'LSL', 'LTL', 'LVL', 'LYD', 'MAD', 'MDL', 'MGA', 'MKD', 'MMK', 'MNT', 'MOP', 'MRO', 'MUR', 'MVR', 'MWK', 'MXN', 'MYR', 'MZM', 'NAD', 'NGN', 'NIO', 'NOK', 'NPR', 'NRs', 'NZD', 'OMR', 'PAB', 'PEN', 'PGK', 'PHP', 'PKR', 'PLN', 'PYG', 'QAR', 'RMB', 'RON', 'RSD', 'RUB', 'RWF', 'SAR', 'SCR', 'SDG', 'SDR', 'SEK', 'SGD', 'SHP', 'SOS', 'SRD', 'STD', 'SYP', 'SZL', 'THB', 'TJS', 'TMT', 'TND', 'TRY', 'TTD', 'TWD', 'TZS', 'UAE', 'UAH', 'UGX', 'USD', 'USh', 'UYU', 'UZS', 'VEB', 'VND', 'VUV', 'WST', 'XAF', 'XCD', 'XDR', 'XOF', 'XPF', 'YEN', 'YER', 'YTL', 'ZAR', 'ZMK', 'ZWR'];
|
||||
currency = d.widgets['Default Currency'];
|
||||
add_sel_options(currency, currency_list);
|
||||
}
|
||||
|
||||
|
||||
// validate fields
|
||||
// ---------------
|
||||
pscript.validate_fields = function(d)
|
||||
{
|
||||
var lst = ['Company Abbreviation', 'Fiscal Year Start Date', 'Default Currency'];
|
||||
var msg = 'Please enter the following fields';
|
||||
var flag = 1;
|
||||
for(var i=0; i<lst.length; i++)
|
||||
{
|
||||
if(!d.widgets[lst[i]].value){
|
||||
flag = 0;
|
||||
msg = msg + NEWLINE + lst[i];
|
||||
}
|
||||
}
|
||||
|
||||
if(!flag) alert(msg);
|
||||
return flag;
|
||||
}
|
||||
|
||||
SetupWizard = function(status) {
|
||||
var me = this;
|
||||
$.extend(this, {
|
||||
make: function(status) {
|
||||
me.status = status;
|
||||
me.wrapper = page_body.pages['Event Updates'].setup_wizard_area;
|
||||
$ds(me.wrapper);
|
||||
me.make_percent(status.percent);
|
||||
me.make_suggestion(status.ret);
|
||||
},
|
||||
make_percent: function(percent) {
|
||||
$a(me.wrapper, 'div', 'header', {}, 'Your setup is '+percent+'% complete');
|
||||
var o = $a(me.wrapper, 'div', 'percent-outer');
|
||||
$a(o, 'div', 'percent-inner', {width:percent + '%'});
|
||||
},
|
||||
make_suggestion: function(ret) {
|
||||
me.suggest_area = $a(me.wrapper, 'div', 'suggestion');
|
||||
if(me.status.ret.length>1) {
|
||||
me.prev_next = $a(me.wrapper, 'div', 'prev-next');
|
||||
|
||||
// next
|
||||
me.next = $a(me.prev_next, 'span', 'link_type', null, 'Next Suggestion',
|
||||
function() { me.show_suggestion(me.cur_sugg+1) });
|
||||
|
||||
// prev
|
||||
me.prev = $a(me.prev_next, 'span', 'link_type', null, 'Previous Suggestion',
|
||||
function() { me.show_suggestion(me.cur_sugg-1) });
|
||||
|
||||
}
|
||||
if(me.status.ret.length) {
|
||||
me.show_suggestion(0);
|
||||
} else {
|
||||
me.suggest_area.innerHTML = 'Congratulations: '.bold() + 'You are now on your track... Good luck';
|
||||
}
|
||||
},
|
||||
show_suggestion: function(idx) {
|
||||
me.cur_sugg = idx;
|
||||
me.suggest_area.innerHTML = 'What you can do next: '.bold() + me.status.ret[idx];
|
||||
|
||||
// show hide prev, next
|
||||
if(me.status.ret.length>1) {
|
||||
$dh(me.prev); $dh(me.next);
|
||||
if(idx>0) $ds(me.prev);
|
||||
if(idx<me.status.ret.length-1) $ds(me.next);
|
||||
}
|
||||
}
|
||||
})
|
||||
this.make(status);
|
||||
}
|
||||
@@ -1,91 +0,0 @@
|
||||
import webnotes
|
||||
from webnotes.utils import cint
|
||||
|
||||
def get_online_users():
|
||||
# get users
|
||||
return webnotes.conn.sql("""SELECT DISTINCT t1.user, t2.first_name, t2.last_name
|
||||
from tabSessions t1, tabProfile t2
|
||||
where t1.user = t2.name
|
||||
and t1.user not in ('Guest','Administrator')
|
||||
and TIMESTAMPDIFF(HOUR,t1.lastupdate,NOW()) <= 1""", as_list=1) or []
|
||||
|
||||
#
|
||||
# get unread messages
|
||||
#
|
||||
def get_unread_messages():
|
||||
"returns unread (docstatus-0 messages for a user)"
|
||||
return cint(webnotes.conn.sql("""SELECT COUNT(*) FROM `tabComment Widget Record`
|
||||
WHERE comment_doctype='My Company'
|
||||
AND comment_docname = %s
|
||||
AND ifnull(docstatus,0)=0
|
||||
""", webnotes.user.name)[0][0])
|
||||
|
||||
#
|
||||
# Get toolbar items
|
||||
#
|
||||
def get_status_details(arg=None):
|
||||
from webnotes.utils import cint, date_diff, nowdate
|
||||
|
||||
online = get_online_users()
|
||||
|
||||
# system messages
|
||||
ret = {
|
||||
'user_count': len(online) or 0,
|
||||
'unread_messages': get_unread_messages(),
|
||||
'online_users': online or [],
|
||||
'is_trial': webnotes.conn.get_global('is_trial'),
|
||||
'days_to_expiry': (webnotes.conn.get_global('days_to_expiry') or '0'),
|
||||
'setup_status': get_setup_status()
|
||||
}
|
||||
return ret
|
||||
|
||||
def get_setup_status():
|
||||
"""
|
||||
Returns the setup status of the current account
|
||||
"""
|
||||
if cint(webnotes.conn.get_global('setup_done')):
|
||||
return ''
|
||||
|
||||
percent = 20
|
||||
ret = []
|
||||
|
||||
def is_header_set():
|
||||
header = webnotes.conn.get_value('Control Panel', None, 'client_name') or ''
|
||||
|
||||
if header.startswith('<div style="padding:4px; font-size:20px;">'\
|
||||
+webnotes.conn.get_value('Control Panel', None, 'company_name')):
|
||||
return False
|
||||
|
||||
elif 'Banner Comes Here' in header:
|
||||
return False
|
||||
|
||||
else:
|
||||
return True
|
||||
|
||||
if not is_header_set():
|
||||
ret.append('<a href="#!Form/Personalize/Personalize">Upload your company banner</a>')
|
||||
else:
|
||||
percent += 20
|
||||
|
||||
def check_type(doctype, ret, percent):
|
||||
if not webnotes.conn.sql("select count(*) from tab%s" % doctype)[0][0]:
|
||||
ret.append('''
|
||||
<a href="#!Form/%(dt)s/New">
|
||||
Create a new %(dt)s
|
||||
</a> or
|
||||
<a href="#!Import Data/%(dt)s">
|
||||
Import from a spreadsheet</a>''' % {'dt':doctype})
|
||||
else:
|
||||
percent += 20
|
||||
return ret, percent
|
||||
|
||||
ret, percent = check_type('Item', ret, percent)
|
||||
ret, percent = check_type('Customer', ret, percent)
|
||||
ret, percent = check_type('Supplier', ret, percent)
|
||||
|
||||
if percent==100:
|
||||
webnotes.conn.set_global('setup_done', '1')
|
||||
return ''
|
||||
|
||||
return {'ret': ret, 'percent': percent}
|
||||
|
||||
@@ -1,27 +0,0 @@
|
||||
# Page, Event Updates
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2010-12-14 10:23:23',
|
||||
'docstatus': 0,
|
||||
'modified': '2010-12-27 10:58:56',
|
||||
'modified_by': 'Administrator',
|
||||
'owner': 'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all Page
|
||||
{
|
||||
'doctype': 'Page',
|
||||
'module': 'Home',
|
||||
'name': '__common__',
|
||||
'page_name': 'Event Updates',
|
||||
'standard': 'Yes'
|
||||
},
|
||||
|
||||
# Page, Event Updates
|
||||
{
|
||||
'doctype': 'Page',
|
||||
'name': 'Event Updates'
|
||||
}
|
||||
]
|
||||
@@ -1 +0,0 @@
|
||||
Event Updates
|
||||
@@ -1,82 +0,0 @@
|
||||
/* item */
|
||||
|
||||
div.my-company-member-item-selected {
|
||||
background-color: #BBC;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* profile */
|
||||
.my-company-name-head {
|
||||
font-size: 14px;
|
||||
font-weight: bold;
|
||||
margin-bottom: 7px;
|
||||
}
|
||||
|
||||
.my-company-email {
|
||||
margin-bottom: 7px;
|
||||
color: #888;
|
||||
}
|
||||
|
||||
.my-company-online-status {
|
||||
font-weight: bold;
|
||||
margin-left: 7px;
|
||||
}
|
||||
|
||||
.my-company-status {
|
||||
margin-bottom: 7px;
|
||||
color: #888;
|
||||
font-style: italics;
|
||||
}
|
||||
|
||||
.my-company-bio {
|
||||
margin-bottom: 7px;
|
||||
}
|
||||
|
||||
.my-company-toolbar {
|
||||
margin: 7px 0px;
|
||||
}
|
||||
|
||||
/* conversation */
|
||||
|
||||
.my-company-input-wrapper {
|
||||
color: #555;
|
||||
padding: 13px;
|
||||
}
|
||||
|
||||
.my-company-input-wrapper td {
|
||||
vertical-align: bottom;
|
||||
}
|
||||
|
||||
.my-company-input-wrapper textarea {
|
||||
height: 3em;
|
||||
font-size: 14px;
|
||||
width: 100%;
|
||||
margin: 7px 0px 3px 0px;
|
||||
}
|
||||
|
||||
.my-company-input-wrapper button {
|
||||
margin: 0px;
|
||||
}
|
||||
|
||||
.my-company-conversation {
|
||||
border-top: 1px solid #DDD;
|
||||
}
|
||||
.my-company-comment-wrapper {
|
||||
padding: 7px;
|
||||
border-bottom: 1px solid #DDD;
|
||||
}
|
||||
|
||||
.my-company-timestamp {
|
||||
color: #888;
|
||||
font-size: 11px;
|
||||
margin: 3px;
|
||||
}
|
||||
|
||||
.my-company-conversation-head {
|
||||
padding: 3px;
|
||||
background-color: #DEDEDE;
|
||||
color: #555;
|
||||
font-size: 14px;
|
||||
text-align: center;
|
||||
}
|
||||
@@ -1,923 +0,0 @@
|
||||
pscript['onload_My Company'] = function() {
|
||||
var wrapper = page_body.pages['My Company'];
|
||||
|
||||
// body
|
||||
wrapper.className = 'layout_wrapper';
|
||||
wrapper.head = new PageHeader(wrapper, 'People');
|
||||
wrapper.body = $a(wrapper, 'div', '', {marginRight:'11px', marginTop:'11px'});
|
||||
|
||||
wrapper.message = $a(wrapper.body, 'div');
|
||||
wrapper.tab = make_table(wrapper.body, 1, 2, '100%', ['25%','75%']);
|
||||
|
||||
$y(wrapper.tab, {tableLayout:'fixed'})
|
||||
|
||||
pscript.myc_make_toolbar(wrapper);
|
||||
pscript.myc_make_list(wrapper);
|
||||
|
||||
if(pscript.is_erpnext_saas) {
|
||||
pscript.myc_show_erpnext_message();
|
||||
}
|
||||
}
|
||||
|
||||
pscript.myc_make_toolbar = function(wrapper) {
|
||||
if(has_common(user_roles, ['System Manager', 'Administrator'])) {
|
||||
wrapper.head.add_button('Add User', pscript.myc_add_user)
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Only for erpnext product - show max users allowed
|
||||
//
|
||||
pscript.myc_show_erpnext_message = function() {
|
||||
var callback = function(r, rt) {
|
||||
if(r.exc) {msgprint(r.exc); return;}
|
||||
$a(wrapper.message, 'div', 'help_box', '', 'You have ' + r.message.enabled
|
||||
+ ' users enabled out of ' + r.message.max_user
|
||||
+ '. Go to <a href="javascript:pscript.go_to_account_settings()">Account Settings</a> to increase the number of users');
|
||||
}
|
||||
$c_page('home', 'my_company', 'get_max_users', '', callback)
|
||||
}
|
||||
|
||||
//
|
||||
// Add user dialog and server call
|
||||
//
|
||||
pscript.myc_add_user = function() {
|
||||
var d = new wn.widgets.Dialog({
|
||||
title: 'Add User',
|
||||
width: 400,
|
||||
fields: [
|
||||
{fieldtype:'Data', fieldname:'user',reqd:1,label:'Email Id of the user to add'},
|
||||
{fieldtype:'Button', label:'Add', fieldname:'add'}
|
||||
]
|
||||
});
|
||||
d.make();
|
||||
d.fields_dict.add.input.onclick = function() {
|
||||
v = d.get_values();
|
||||
if(v) {
|
||||
d.fields_dict.add.input.set_working();
|
||||
$c_page('home', 'my_company', 'add_user', v, function(r,rt) {
|
||||
if(r.exc) { msgprint(r.exc); return; }
|
||||
else {
|
||||
d.hide();
|
||||
pscript.myc_refresh();
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
d.show();
|
||||
}
|
||||
|
||||
pscript.myc_refresh = function() {
|
||||
page_body.pages['My Company'].member_list.lst.run();
|
||||
}
|
||||
|
||||
pscript.myc_make_list= function(wrapper) {
|
||||
wrapper.member_list = new MemberList(wrapper)
|
||||
}
|
||||
|
||||
pscript.get_fullname=function(uid) {
|
||||
if(uid=='Administrator') return uid;
|
||||
return page_body.pages['My Company'].member_list.member_items[uid].fullname;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//=============================================
|
||||
|
||||
MemberList = function(parent) {
|
||||
var me = this;
|
||||
this.profiles = {};
|
||||
this.member_items = {};
|
||||
this.role_objects = {};
|
||||
this.cur_profile = null;
|
||||
|
||||
this.list_wrapper = $a($td(parent.tab,0,0), 'div', '', {marginLeft:'11px'});
|
||||
var cell = $td(parent.tab,0,1);
|
||||
$y(cell, { border: '1px solid #aaa' });
|
||||
cell.className = 'layout_wrapper';
|
||||
this.profile_wrapper = $a(cell, 'div');
|
||||
|
||||
this.no_user_selected = $a(this.profile_wrapper, 'div', 'help_box', null, 'Please select a user to view profile');
|
||||
|
||||
this.make_search();
|
||||
if(pscript.online_users) {
|
||||
this.make_list();
|
||||
} else {
|
||||
$c_page('home', 'event_updates', 'get_online_users', '', function(r,rt) {
|
||||
pscript.online_users = r.message;
|
||||
me.make_list();
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// ----------------------
|
||||
|
||||
MemberList.prototype.make_search = function() {
|
||||
var me = this;
|
||||
this.search_area = $a(this.list_wrapper, 'div', '', {textAlign:'center', padding:'8px'});
|
||||
this.search_inp = $a(this.search_area, 'input', '', {fontSize:'14px', width:'80%'});
|
||||
this.search_inp.set_empty = function() {
|
||||
this.value = 'Search'; $fg(this,'#888');
|
||||
}
|
||||
this.search_inp.onfocus = function() {
|
||||
$fg(this,'#000');
|
||||
if(this.value=='Search')this.value = '';
|
||||
}
|
||||
this.search_inp.onchange = function() {
|
||||
if(!this.value) this.set_empty();
|
||||
}
|
||||
this.search_inp.set_empty();
|
||||
}
|
||||
|
||||
// ----------------------
|
||||
|
||||
MemberList.prototype.make_list = function() {
|
||||
var me = this;
|
||||
this.lst_area = $a(this.list_wrapper, 'div');
|
||||
|
||||
this.lst = new wn.widgets.Listing({
|
||||
parent: this.lst_area,
|
||||
as_dict: 1,
|
||||
get_query: function() {
|
||||
var c1 = '';
|
||||
if(me.search_inp.value && me.search_inp.value != 'Search') {
|
||||
var c1 = repl(' AND (first_name LIKE "%(txt)s" OR last_name LIKE "%(txt)s" OR name LIKE "%(txt)s")', {txt:'%' + me.search_inp.value + '%'});
|
||||
}
|
||||
|
||||
return repl("SELECT name, \
|
||||
ifnull(concat_ws(' ', first_name, last_name),'') as full_name, \
|
||||
gender, file_list, enabled \
|
||||
FROM tabProfile \
|
||||
WHERE docstatus != 2 \
|
||||
AND name not in ('Guest','Administrator') %(cond)s \
|
||||
ORDER BY name asc",{cond:c1});
|
||||
},
|
||||
render_row: function(parent, data) {
|
||||
me.member_items[data.name] = new MemberItem(parent, data, me);
|
||||
}
|
||||
});
|
||||
this.lst.run();
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Create / show profile
|
||||
*/
|
||||
MemberList.prototype.show_profile = function(uid, member_item) {
|
||||
$dh(this.no_user_selected);
|
||||
|
||||
// if not exists, create
|
||||
if(!this.profiles[uid]) {
|
||||
if(!member_item) member_item = this.member_items[uid];
|
||||
this.profiles[uid] = new MemberProfile(this.profile_wrapper, uid, member_item);
|
||||
}
|
||||
|
||||
// hide current
|
||||
if(this.cur_profile)
|
||||
this.cur_profile.hide();
|
||||
|
||||
// show this
|
||||
this.profiles[uid].show();
|
||||
this.cur_profile = this.profiles[uid];
|
||||
}
|
||||
|
||||
|
||||
// Member Item
|
||||
// List item of all profiles
|
||||
// on the left hand sidebar of the page
|
||||
|
||||
MemberItem = function(parent, det, mlist) {
|
||||
var me = this;
|
||||
this.det = det;
|
||||
this.wrapper = $a(parent, 'div');
|
||||
this.enabled = det.enabled;
|
||||
|
||||
this.tab = make_table(this.wrapper, 1,2,'100%', ['20%', '70%'], {padding:'4px', overflow:'hidden'});
|
||||
$y(this.tab, {tableLayout:'fixed', borderCollapse:'collapse'})
|
||||
|
||||
this.is_online = function() {
|
||||
for(var i=0;i<pscript.online_users.length;i++) {
|
||||
if(det.name==pscript.online_users[i][0]) return true;
|
||||
}
|
||||
}
|
||||
|
||||
this.refresh_name_link = function() {
|
||||
// online / offline
|
||||
$fg(this.name_link,'#00B');
|
||||
if(!this.is_online())
|
||||
$fg(this.name_link,'#444');
|
||||
if(!this.enabled)
|
||||
$fg(this.name_link,'#777');
|
||||
|
||||
}
|
||||
|
||||
this.set_image = function() {
|
||||
// image
|
||||
this.img = $a($td(this.tab,0,0),'img','',{width:'41px'});
|
||||
set_user_img(this.img, det.name, null,
|
||||
(det.file_list ? det.file_list.split(NEWLINE)[0].split(',')[1] : ('no_img_' + (det.gender=='Female' ? 'f' : 'm'))));
|
||||
}
|
||||
|
||||
// set other details like email id, name etc
|
||||
this.set_details = function() {
|
||||
// name
|
||||
this.fullname = det.full_name || det.name;
|
||||
var div = $a($td(this.tab, 0, 1), 'div', '', {fontWeight: 'bold',padding:'2px 0px'});
|
||||
this.name_link = $a(div,'span','link_type');
|
||||
this.name_link.innerHTML = crop(this.fullname, 15);
|
||||
this.name_link.onclick = function() {
|
||||
mlist.show_profile(me.det.name, me);
|
||||
}
|
||||
|
||||
// "you" tag
|
||||
if(user==det.name) {
|
||||
var span = $a(div,'span','',{padding:'2px' ,marginLeft:'3px'});
|
||||
span.innerHTML = '(You)'
|
||||
}
|
||||
|
||||
// email id
|
||||
var div = $a($td(this.tab, 0, 1), 'div', '', {color: '#777', fontSize:'11px'});
|
||||
div.innerHTML = det.name;
|
||||
|
||||
// working img
|
||||
var div = $a($td(this.tab, 0, 1), 'div');
|
||||
this.working_img = $a(div,'img','',{display:'none'});
|
||||
this.working_img.src = 'images/ui/button-load.gif';
|
||||
|
||||
this.refresh_name_link();
|
||||
|
||||
}
|
||||
|
||||
this.select = function() {
|
||||
$(this.wrapper).addClass('my-company-member-item-selected');
|
||||
}
|
||||
|
||||
this.deselect = function() {
|
||||
$(this.wrapper).removeClass('my-company-member-item-selected');
|
||||
}
|
||||
|
||||
this.set_image();
|
||||
this.set_details();
|
||||
|
||||
// show initial
|
||||
if(user==det.name) me.name_link.onclick();
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Member Profile
|
||||
// shows profile with Photo and conversation
|
||||
//
|
||||
MemberProfile = function(parent, uid, member_item) {
|
||||
this.parent = parent;
|
||||
this.uid = uid;
|
||||
this.member_item = member_item;
|
||||
var me = this;
|
||||
|
||||
// make the UI
|
||||
this.make = function() {
|
||||
this.wrapper = $a(this.parent, 'div', '', {display:'none'});
|
||||
this.tab = make_table(this.wrapper, 3, 2,'100%',['120px',null],{padding:'3px'});
|
||||
$y(this.tab, {tableLayout: 'fixed'});
|
||||
|
||||
this.make_image_and_bio();
|
||||
this.make_toolbar();
|
||||
this.make_message_list();
|
||||
}
|
||||
|
||||
// create elements
|
||||
this.make_image_and_bio = function() {
|
||||
var rh = $td(this.tab, 0, 1);
|
||||
|
||||
// image
|
||||
this.img = $a($td(this.tab, 0, 0), 'img','',{width:'80px', marginLeft:'10px'});
|
||||
set_user_img(this.img, this.uid);
|
||||
|
||||
// details
|
||||
this.name_area = $a(rh, 'div' , 'my-company-name-head');
|
||||
var div = $a(rh, 'div', 'my-company-email');
|
||||
this.email_area = $a(div, 'span');
|
||||
this.online_status_area = $a(div, 'span', 'my-company-online-status');
|
||||
this.bio_area = $a(rh, 'div', 'my-company-bio');
|
||||
this.toolbar_area = $a(rh, 'div', 'my-company-toolbar');
|
||||
this.status_span = $a(this.toolbar_area, 'span', '', {marginRight:'7px'});
|
||||
|
||||
}
|
||||
|
||||
// the toolbar
|
||||
this.make_toolbar = function() {
|
||||
if(has_common(['Administrator','System Manager'],user_roles)) {
|
||||
var roles_btn = $btn(this.toolbar_area, 'Set Roles', function() { me.show_roles() },{marginRight:'3px'});
|
||||
var delete_btn = $btn(this.toolbar_area, 'Delete User', function() { me.delete_user(); },{marginRight:'3px'});
|
||||
var ip_btn = $btn(this.toolbar_area, 'Securty Settings', function() { me.set_security(); },{marginRight:'3px'});
|
||||
}
|
||||
}
|
||||
|
||||
// create the role object
|
||||
this.show_roles = function() {
|
||||
if(!this.role_object)
|
||||
this.role_object = new RoleObj(this.uid);
|
||||
this.role_object.dialog.show();
|
||||
}
|
||||
|
||||
// show securty settings
|
||||
this.set_security = function() {
|
||||
var d = new wn.widgets.Dialog({
|
||||
title: 'Set User Security',
|
||||
width: 500,
|
||||
fields: [
|
||||
{
|
||||
label:'IP Address',
|
||||
description: 'Restrict user login by IP address, partial ips (111.111.111), \
|
||||
multiple addresses (separated by commas) allowed',
|
||||
fieldname:'restrict_ip',
|
||||
fieldtype:'Data'
|
||||
},
|
||||
|
||||
{
|
||||
label:'Login After',
|
||||
description: 'User can only login after this hour (0-24)',
|
||||
fieldtype: 'Int',
|
||||
fieldname: 'login_after'
|
||||
},
|
||||
|
||||
{
|
||||
label:'Login Before',
|
||||
description: 'User can only login before this hour (0-24)',
|
||||
fieldtype: 'Int',
|
||||
fieldname: 'login_before'
|
||||
},
|
||||
|
||||
{
|
||||
label:'New Password',
|
||||
description: 'Update the current user password',
|
||||
fieldtype: 'Data',
|
||||
fieldname: 'new_password'
|
||||
},
|
||||
|
||||
{
|
||||
label:'Update',
|
||||
fieldtype:'Button',
|
||||
fieldname:'update'
|
||||
}
|
||||
]
|
||||
});
|
||||
d.onshow = function() {
|
||||
d.set_values({
|
||||
restrict_ip: me.profile.restrict_ip || '',
|
||||
login_before: me.profile.login_before || '',
|
||||
login_after: me.profile.login_after || '',
|
||||
new_password: ''
|
||||
})
|
||||
}
|
||||
d.fields_dict.update.input.onclick = function() {
|
||||
var btn = this;
|
||||
this.set_working();
|
||||
var args = d.get_values();
|
||||
args.user = me.profile.name;
|
||||
$c_page('home', 'my_company', 'update_security', JSON.stringify(args), function(r,rt) {
|
||||
if(r.exc) {
|
||||
msgprint(r.exc);
|
||||
btn.done_working();
|
||||
return;
|
||||
}
|
||||
$.extend(me.profile, d.get_values());
|
||||
d.hide();
|
||||
});
|
||||
}
|
||||
d.show();
|
||||
}
|
||||
|
||||
// delete user
|
||||
// create a confirm dialog and call server method
|
||||
this.delete_user = function() {
|
||||
var cp = locals['Control Panel']['Control Panel'];
|
||||
|
||||
var d = new Dialog(400,200,'Delete User');
|
||||
d.make_body([
|
||||
['HTML','','Do you really want to remove '+this.uid+' from system?'],['Button','Delete']
|
||||
]);
|
||||
d.onshow = function() {
|
||||
this.clear_inputs();
|
||||
}
|
||||
|
||||
d.widgets['Delete'].onclick = function() {
|
||||
this.set_working();
|
||||
|
||||
var callback = function(r,rt) {
|
||||
d.hide();
|
||||
if(r.exc) {
|
||||
msgprint(r.exc);
|
||||
return;
|
||||
}
|
||||
pscript.myc_refresh()
|
||||
msgprint("User Deleted Successfully");
|
||||
}
|
||||
$c_page('home', 'my_company', 'delete_user', {'user': me.uid}, callback);
|
||||
}
|
||||
d.show();
|
||||
}
|
||||
|
||||
// set enabled
|
||||
this.set_enable_button = function() {
|
||||
var me = this;
|
||||
var act = this.profile.enabled ? 'Disable' : 'Enable';
|
||||
|
||||
if(this.status_button) {
|
||||
this.status_button.innerHTML = act;
|
||||
} else {
|
||||
// make the button
|
||||
this.status_button = $btn(this.toolbar_area, act, function() {
|
||||
var callback = function(r,rt) {
|
||||
locals['Profile'][me.profile.name].enabled = cint(r.message);
|
||||
me.status_button.done_working();
|
||||
me.refresh_enable_disable();
|
||||
}
|
||||
this.set_working();
|
||||
$c_page('home','my_company', this.innerHTML.toLowerCase()+'_profile',me.profile.name, callback);
|
||||
}, null, null, 1);
|
||||
}
|
||||
if(this.uid==user) $dh(this.status_button); else $di(this.status_button);
|
||||
}
|
||||
|
||||
// render the details of the user from Profile
|
||||
this.render = function() {
|
||||
this.profile = locals['Profile'][uid];
|
||||
scroll(0, 0);
|
||||
|
||||
// name
|
||||
if(cstr(this.profile.first_name) || cstr(this.profile.last_name)) {
|
||||
this.fullname = cstr(this.profile.first_name) + ' ' + cstr(this.profile.last_name);
|
||||
} else {
|
||||
this.fullname = this.profile.name;
|
||||
}
|
||||
this.name_area.innerHTML = this.fullname;
|
||||
|
||||
// email
|
||||
this.email_area.innerHTML = this.profile.name;
|
||||
|
||||
// online / offline
|
||||
this.online_status_area.innerHTML = (this.member_item.is_online() ? '(Online)' : '(Offline)')
|
||||
if(this.member_item.is_online()) {
|
||||
$y(this.online_status_area, {color:'green'});
|
||||
}
|
||||
|
||||
// refresh enable / disabled
|
||||
this.refresh_enable_disable();
|
||||
|
||||
// designation
|
||||
this.bio_area.innerHTML = this.profile.designation ? ('Designation: ' + cstr(this.profile.designation) + '<br>') : '';
|
||||
this.bio_area.innerHTML += this.profile.bio ? this.profile.bio : 'No bio';
|
||||
|
||||
new MemberConversation(this.wrapper, this.profile.name, this.fullname);
|
||||
}
|
||||
|
||||
// refresh enable / disable
|
||||
this.refresh_enable_disable = function() {
|
||||
this.profile = locals['Profile'][this.uid]
|
||||
|
||||
if(!this.profile.enabled) {
|
||||
$fg(this.name_area,'#999');
|
||||
} else {
|
||||
$fg(this.name_area,'#000');
|
||||
}
|
||||
|
||||
this.member_item.enabled = this.profile.enabled;
|
||||
this.member_item.refresh_name_link();
|
||||
|
||||
this.status_span.innerHTML = this.profile.enabled ? 'Enabled' : 'Disabled';
|
||||
|
||||
// set styles and buttons
|
||||
if(has_common(['Administrator','System Manager'],user_roles)) {
|
||||
this.set_enable_button();
|
||||
}
|
||||
}
|
||||
|
||||
// Load user profile (if not loaded)
|
||||
this.load = function() {
|
||||
if(locals['Profile'] && locals['Profile'][uid]) {
|
||||
this.render();
|
||||
return;
|
||||
}
|
||||
var callback = function(r,rt) {
|
||||
$dh(me.member_item.working_img);
|
||||
$ds(me.wrapper);
|
||||
me.loading = 0;
|
||||
me.render();
|
||||
}
|
||||
$ds(this.member_item.working_img);
|
||||
$dh(this.wrapper);
|
||||
this.loading = 1;
|
||||
$c('webnotes.widgets.form.getdoc', {'name':this.uid, 'doctype':'Profile', 'user':user}, callback); // onload
|
||||
}
|
||||
|
||||
// show / hide
|
||||
this.show = function() {
|
||||
if(!this.loading)$ds(this.wrapper);
|
||||
|
||||
// select profile
|
||||
this.member_item.select();
|
||||
}
|
||||
this.hide = function() {
|
||||
$dh(this.wrapper);
|
||||
|
||||
// select profile
|
||||
this.member_item.deselect();
|
||||
}
|
||||
|
||||
this.make_message_list = function() {
|
||||
|
||||
}
|
||||
|
||||
this.make();
|
||||
this.load();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// Member conversation
|
||||
// Between the current user and the displayed profile
|
||||
// or if same, then the conversation with all other
|
||||
// profiles
|
||||
MemberConversation = function(parent, uid, fullname) {
|
||||
var me = this;
|
||||
this.wrapper = $a(parent, 'div', 'my-company-conversation');
|
||||
this.fullname = fullname;
|
||||
this.make = function() {
|
||||
if(user!=uid) {
|
||||
this.make_input();
|
||||
}
|
||||
this.make_list();
|
||||
|
||||
// set all messages
|
||||
// as "read" (docstatus = 0)
|
||||
if(user==uid) {
|
||||
$c_page('home', 'my_company', 'set_read_all_messages', '', function(r,rt) { });
|
||||
}
|
||||
}
|
||||
|
||||
this.make_input = function() {
|
||||
this.input_wrapper = $a(this.wrapper, 'div', 'my-company-input-wrapper');
|
||||
var tab = make_table(this.input_wrapper, 1, 2, '100%', ['64%','36%'], {padding: '3px'})
|
||||
this.input = $a($td(tab,0,0), 'textarea');
|
||||
$(this.input).add_default_text( 'Send a message to ' + fullname);
|
||||
|
||||
// button
|
||||
var div = $a(this.input_wrapper, 'div');
|
||||
this.post = $btn(div, 'Post'.bold(), function() { me.post_message(); }, {margin:'0px 13px 0px 3px'})
|
||||
this.post.set_disabled();
|
||||
this.input.onkeyup = this.input.onchange = function() {
|
||||
if(this.value) {
|
||||
me.post.set_enabled();
|
||||
} else {
|
||||
me.post.set_disabled();
|
||||
}
|
||||
}
|
||||
|
||||
// notification check
|
||||
this.notify_check = $a_input(div, 'checkbox', null);
|
||||
$a(div, 'span', '', {marginLeft:'3px'}, 'Notify ' + fullname + ' by email')
|
||||
}
|
||||
|
||||
this.post_message = function() {
|
||||
if(me.input.value==$(me.input).attr('default_text')) {
|
||||
msgprint('Please write a message first!'); return;
|
||||
}
|
||||
this.post.set_working();
|
||||
$c_page('home', 'my_company', 'post_comment', {
|
||||
uid: uid,
|
||||
comment: $(me.input).val(),
|
||||
notify: me.notify_check.checked ? 1 : 0
|
||||
}, function(r,rt) {
|
||||
$(me.input).val("").blur();
|
||||
me.post.done_working();
|
||||
if(r.exc) { msgprint(r.exc); return; }
|
||||
me.notify_check.checked = false;
|
||||
me.refresh();
|
||||
})
|
||||
}
|
||||
|
||||
this.make_list = function() {
|
||||
this.lst_area = $a(this.wrapper, 'div', 'my-company-conversation', {padding:'7px 13px'});
|
||||
|
||||
if(user==uid) {
|
||||
this.my_messages_box = $a(this.lst_area, 'div', 'my-company-conversation-head', {marginBottom:'7px'}, 'Messages by everyone to me<br>To send a message, click on the user on the left')
|
||||
}
|
||||
|
||||
this.lst = new wn.widgets.Listing({
|
||||
parent: this.lst_area,
|
||||
as_dict: 1,
|
||||
no_result_message: (user==uid
|
||||
? 'No messages by anyone yet'
|
||||
: 'No messages yet. To start a conversation post a new message'),
|
||||
|
||||
get_query: function() {
|
||||
if(uid==user) {
|
||||
return repl("SELECT comment, owner, comment_docname, creation, docstatus " +
|
||||
"FROM `tabComment Widget Record` "+
|
||||
"WHERE comment_doctype='My Company' " +
|
||||
"AND comment_docname='%(user)s' " +
|
||||
"ORDER BY creation DESC ", {user:user});
|
||||
|
||||
} else {
|
||||
return repl("SELECT comment, owner, comment_docname, creation, docstatus " +
|
||||
"FROM `tabComment Widget Record` "+
|
||||
"WHERE comment_doctype='My Company' " +
|
||||
"AND ((owner='%(user)s' AND comment_docname='%(uid)s') " +
|
||||
"OR (owner='%(uid)s' AND comment_docname='%(user)s')) " +
|
||||
"ORDER BY creation DESC ", {uid:uid, user:user});
|
||||
|
||||
}
|
||||
},
|
||||
render_row: function(parent, data) {
|
||||
new MemberCoversationComment(parent, data, me);
|
||||
},
|
||||
|
||||
})
|
||||
this.refresh();
|
||||
}
|
||||
|
||||
this.refresh = function() {
|
||||
me.lst.run()
|
||||
}
|
||||
|
||||
this.make();
|
||||
}
|
||||
|
||||
MemberCoversationComment = function(cell, det, conv) {
|
||||
var me = this;
|
||||
this.det = det;
|
||||
this.wrapper = $a(cell, 'div', 'my-company-comment-wrapper');
|
||||
this.comment = $a(this.wrapper, 'div', 'my-company-comment');
|
||||
|
||||
this.user = $a(this.comment, 'span', 'link_type', {fontWeight:'bold'}, pscript.get_fullname(det.owner));
|
||||
this.user.onclick = function() {
|
||||
page_body.pages['My Company'].member_list.show_profile(me.det.owner);
|
||||
}
|
||||
|
||||
var st = (!det.docstatus ? {fontWeight: 'bold'} : null);
|
||||
this.msg = $a(this.comment, 'span', 'social', st, ': ' + det.comment);
|
||||
|
||||
if(det.full_name==user) {
|
||||
$y(this.wrapper, {backgroundColor: '#D9D9F3'});
|
||||
}
|
||||
this.timestamp = $a(this.wrapper, 'div', 'my-company-timestamp', '', comment_when(det.creation));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// ========================== Role object =====================================
|
||||
|
||||
pscript.all_roles = null;
|
||||
|
||||
RoleObj = function(profile_id){
|
||||
this.roles_dict = {};
|
||||
this.profile_id = profile_id;
|
||||
this.setup_done = 0;
|
||||
|
||||
var d = new Dialog(500,500,'Assign Roles');
|
||||
d.make_body([
|
||||
['HTML','roles']
|
||||
]);
|
||||
|
||||
this.dialog = d;
|
||||
this.make_role_body(profile_id);
|
||||
this.make_help_body();
|
||||
|
||||
this.body.innerHTML = '<span style="color:#888">Loading...</span> <img src="images/ui/button-load.gif">'
|
||||
var me=this;
|
||||
|
||||
d.onshow = function() {
|
||||
if(!me.setup_done)
|
||||
me.get_all_roles(me.profile_id);
|
||||
}
|
||||
}
|
||||
|
||||
// make role body
|
||||
RoleObj.prototype.make_role_body = function(id){
|
||||
var me = this;
|
||||
var d = this.dialog;
|
||||
this.role_div = $a(d.widgets['roles'],'div');
|
||||
|
||||
this.head = $a(this.role_div,'div','',{marginLeft:'4px', marginBottom:'4px',fontWeight:'bold'});
|
||||
this.body = $a(this.role_div,'div');
|
||||
this.footer = $a(this.role_div,'div');
|
||||
|
||||
this.update_btn = $btn(this.footer,'Update',function() { me.update_roles(me.profile_id); },{marginRight:'4px'},'',1);
|
||||
}
|
||||
|
||||
// make help body
|
||||
RoleObj.prototype.make_help_body = function(){
|
||||
var me = this;
|
||||
|
||||
var d = this.dialog;
|
||||
this.help_div = $a(d.widgets['roles'],'div');
|
||||
|
||||
var head = $a(this.help_div,'div'); this.help_div.head = head;
|
||||
var body = $a(this.help_div,'div'); this.help_div.body = body;
|
||||
var tail = $a(this.help_div,'div'); this.help_div.tail = tail;
|
||||
|
||||
var back_btn = $btn(tail,'Back', function() {
|
||||
// back to assign roles
|
||||
$(me.role_div).slideToggle('medium');
|
||||
$(me.help_div).slideToggle('medium');
|
||||
});
|
||||
this.help_div.back_btn = back_btn;
|
||||
$dh(this.help_div);
|
||||
}
|
||||
|
||||
// get all roles
|
||||
RoleObj.prototype.get_all_roles = function(id){
|
||||
if(pscript.all_roles) {
|
||||
this.make_roles(id);
|
||||
return;
|
||||
}
|
||||
|
||||
var me = this;
|
||||
var callback = function(r,rt){
|
||||
pscript.all_roles = r.message;
|
||||
me.make_roles(id);
|
||||
}
|
||||
$c_obj('Company Control','get_all_roles','',callback);
|
||||
}
|
||||
|
||||
// make roles
|
||||
RoleObj.prototype.make_roles = function(id){
|
||||
var me = this;
|
||||
var list = pscript.all_roles;
|
||||
me.setup_done = 1;
|
||||
me.body.innerHTML = '';
|
||||
|
||||
var tbl = make_table( me.body, cint(list.length / 2) + 1,4,'100%',['5%','45%','5%','45%'],{padding:'4px'});
|
||||
var in_right = 0; var ridx = 0;
|
||||
|
||||
for(i=0;i<list.length;i++){
|
||||
var cidx = in_right * 2;
|
||||
|
||||
me.make_checkbox(tbl, ridx, cidx, list[i]);
|
||||
me.make_label(tbl, ridx, cidx + 1, list[i]);
|
||||
|
||||
// change column
|
||||
if(in_right) {in_right = 0; ridx++ } else in_right = 1;
|
||||
}
|
||||
me.get_user_roles(id);
|
||||
}
|
||||
|
||||
// make checkbox
|
||||
RoleObj.prototype.make_checkbox = function(tbl,ridx,cidx, role){
|
||||
var me = this;
|
||||
|
||||
var a = $a_input($a($td(tbl, ridx, cidx),'div'),'checkbox');
|
||||
a.role = role;
|
||||
me.roles_dict[role] = a;
|
||||
|
||||
$y(a,{width:'20px'});
|
||||
$y($td(tbl, ridx, cidx),{textAlign:'right'});
|
||||
}
|
||||
|
||||
|
||||
// make label
|
||||
RoleObj.prototype.make_label = function(tbl, ridx, cidx, role){
|
||||
var me = this;
|
||||
|
||||
var t = make_table($td(tbl, ridx, cidx),1,2,null,['16px', null],{marginRight:'5px'});
|
||||
var ic = $a($td(t,0,0), 'img','',{cursor:'pointer', marginRight:'5px'});
|
||||
ic.src= 'images/icons/help.gif';
|
||||
ic.role = role;
|
||||
|
||||
ic.onclick = function(){
|
||||
me.get_permissions(this.role);
|
||||
}
|
||||
$td(t,0,1).innerHTML= role;
|
||||
|
||||
}
|
||||
|
||||
// get user roles
|
||||
RoleObj.prototype.get_user_roles = function(id){
|
||||
var me = this;
|
||||
me.head.innerHTML = 'Roles for ' + id;
|
||||
|
||||
$ds(me.role_div);
|
||||
$dh(me.help_div);
|
||||
|
||||
var callback = function(r,rt){
|
||||
me.set_user_roles(r.message);
|
||||
}
|
||||
$c_obj('Company Control','get_user_roles', id,callback);
|
||||
}
|
||||
|
||||
|
||||
// set user roles
|
||||
RoleObj.prototype.set_user_roles = function(list){
|
||||
var me = this;
|
||||
for(d in me.roles_dict){
|
||||
me.roles_dict[d].checked = 0;
|
||||
}
|
||||
for(l=0; l<list.length; l++){
|
||||
me.roles_dict[list[l]].checked = 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// update roles
|
||||
RoleObj.prototype.update_roles = function(id){
|
||||
var me = this;
|
||||
|
||||
|
||||
if(id == user && has_common(['System Manager'], user_roles) && !me.roles_dict['System Manager'].checked){
|
||||
var callback = function(r,rt){
|
||||
if(r.message){
|
||||
if(r.message > 1){
|
||||
var c = confirm("You have unchecked the System Manager role.\nYou will lose administrative rights and will not be able to set roles.\n\nDo you want to continue anyway?");
|
||||
if(!c) return;
|
||||
}
|
||||
else{
|
||||
var c = "There should be atleast one user with System Manager role.";
|
||||
me.roles_dict['System Manager'].checked = 1;
|
||||
}
|
||||
}
|
||||
me.set_roles(id);
|
||||
}
|
||||
$c_obj('Company Control','get_sm_count','',callback);
|
||||
}
|
||||
else{
|
||||
me.set_roles(id);
|
||||
}
|
||||
}
|
||||
|
||||
// set roles
|
||||
RoleObj.prototype.set_roles = function(id){
|
||||
|
||||
var me = this;
|
||||
var role_list = [];
|
||||
|
||||
for(d in me.roles_dict){
|
||||
if(me.roles_dict[d].checked){
|
||||
role_list.push(d);
|
||||
}
|
||||
}
|
||||
|
||||
var callback = function(r,rt){
|
||||
me.update_btn.done_working();
|
||||
me.dialog.hide();
|
||||
}
|
||||
var arg = {'usr':id, 'role_list':role_list};
|
||||
me.update_btn.set_working();
|
||||
$c_obj('Company Control','update_roles',docstring(arg), callback);
|
||||
|
||||
}
|
||||
|
||||
// get permission
|
||||
RoleObj.prototype.get_permissions = function(role){
|
||||
var me = this;
|
||||
|
||||
var callback = function(r,rt){
|
||||
$(me.help_div).slideToggle('medium');
|
||||
$(me.role_div).slideToggle('medium');
|
||||
me.set_permissions(r.message, role);
|
||||
}
|
||||
$c_obj('Company Control','get_permission',role,callback);
|
||||
}
|
||||
|
||||
|
||||
// set permission
|
||||
RoleObj.prototype.set_permissions = function(perm, role){
|
||||
var me = this;
|
||||
me.help_div.body.innerHTML ='';
|
||||
|
||||
if(perm){
|
||||
me.help_div.head.innerHTML = 'Permissions for ' + role + ':<br><br>';
|
||||
|
||||
perm_tbl = make_table(me.help_div.body,cint(perm.length)+2,7,'100%',['30%','10%','10%','10%','10%','10%','10%'],{padding:'4px'});
|
||||
|
||||
var head_lst = ['Document','Read','Write','Create','Submit','Cancel','Amend'];
|
||||
|
||||
for(var i=0; i<(head_lst.length-1);i++){
|
||||
$td(perm_tbl,0,i).innerHTML= "<b>"+head_lst[i]+"</b>";
|
||||
}
|
||||
var accept_img1 = 'images/icons/accept.gif';
|
||||
var cancel_img1 = 'images/icons/cancel.gif';
|
||||
|
||||
for(i=1; i<perm.length+1; i++){
|
||||
$td(perm_tbl,i,0).innerHTML= get_doctype_label(perm[i-1][0]);
|
||||
|
||||
for(var j=1;j<(head_lst.length-1);j++){
|
||||
|
||||
if(perm[i-1][j]){
|
||||
var accept_img = $a($td(perm_tbl,i,j), 'img'); accept_img.src= accept_img1;
|
||||
}
|
||||
else {
|
||||
var cancel_img = $a($td(perm_tbl,i,j), 'img'); cancel_img.src= cancel_img1;
|
||||
}
|
||||
$y($td(perm_tbl,i,j),{textAlign:'center'});
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
me.help_div.head.innerHTML = 'No Permission set for ' + role + '.<br><br>';
|
||||
}
|
||||
@@ -1,147 +0,0 @@
|
||||
import webnotes
|
||||
|
||||
from webnotes.utils import cint, load_json, cstr
|
||||
|
||||
try: import json
|
||||
except: import simplejson as json
|
||||
|
||||
def get_account_settings_url(arg=''):
|
||||
import server_tools.gateway_utils
|
||||
return server_tools.gateway_utils.get_account_settings_url()
|
||||
|
||||
#
|
||||
# set max users
|
||||
#
|
||||
def get_max_users(arg=''):
|
||||
from server_tools.gateway_utils import get_max_users_gateway
|
||||
return {
|
||||
'max_users': get_max_users_gateway(),
|
||||
'enabled': cint(webnotes.conn.sql("select count(*) from tabProfile where ifnull(enabled,0)=1 and name not in ('Administrator', 'Guest')")[0][0])
|
||||
}
|
||||
|
||||
#
|
||||
# enable profile in local
|
||||
#
|
||||
def enable_profile(arg=''):
|
||||
webnotes.conn.sql("update tabProfile set enabled=1 where name=%s", arg)
|
||||
return 1
|
||||
|
||||
#
|
||||
# disable profile in local
|
||||
#
|
||||
def disable_profile(arg=''):
|
||||
if arg=='Administrator':
|
||||
return 'Cannot disable Administrator'
|
||||
|
||||
webnotes.conn.sql("update tabProfile set enabled=0 where name=%s", arg)
|
||||
return 0
|
||||
|
||||
#
|
||||
# delete user
|
||||
#
|
||||
def delete_user(args):
|
||||
args = json.loads(args)
|
||||
webnotes.conn.sql("update tabProfile set enabled=0, docstatus=2 where name=%s", args['user'])
|
||||
# erpnext-saas
|
||||
if cint(webnotes.conn.get_value('Control Panel', None, 'sync_with_gateway')):
|
||||
from server_tools.gateway_utils import remove_user_gateway
|
||||
remove_user_gateway(args['user'])
|
||||
|
||||
#
|
||||
# add user
|
||||
#
|
||||
def add_user(args):
|
||||
args = json.loads(args)
|
||||
# erpnext-saas
|
||||
if cint(webnotes.conn.get_value('Control Panel', None, 'sync_with_gateway')):
|
||||
from server_tools.gateway_utils import add_user_gateway
|
||||
add_user_gateway(args['user'])
|
||||
|
||||
add_profile(args['user'])
|
||||
|
||||
#
|
||||
# add profile record
|
||||
#
|
||||
def add_profile(email):
|
||||
from webnotes.utils import validate_email_add
|
||||
from webnotes.model.doc import Document
|
||||
|
||||
sql = webnotes.conn.sql
|
||||
|
||||
if not email:
|
||||
email = webnotes.form_dict.get('user')
|
||||
if not validate_email_add(email):
|
||||
raise Exception
|
||||
return 'Invalid Email Id'
|
||||
|
||||
if sql("select name from tabProfile where name = %s", email):
|
||||
# exists, enable it
|
||||
sql("update tabProfile set enabled = 1, docstatus=0 where name = %s", email)
|
||||
webnotes.msgprint('Profile exists, enabled it')
|
||||
else:
|
||||
# does not exist, create it!
|
||||
pr = Document('Profile')
|
||||
pr.name = email
|
||||
pr.email = email
|
||||
pr.enabled=1
|
||||
pr.user_type='System User'
|
||||
pr.save(1)
|
||||
|
||||
#
|
||||
# post comment
|
||||
#
|
||||
def post_comment(arg):
|
||||
arg = load_json(arg)
|
||||
|
||||
from webnotes.model.doc import Document
|
||||
d = Document('Comment Widget Record')
|
||||
d.comment_doctype = 'My Company'
|
||||
d.comment_docname = arg['uid'] # to
|
||||
d.owner = webnotes.user.name
|
||||
d.comment = arg['comment']
|
||||
d.save(1)
|
||||
|
||||
if cint(arg['notify']):
|
||||
fn = webnotes.conn.sql('select first_name, last_name from tabProfile where name=%s', webnotes.user.name)[0]
|
||||
if fn[0] or f[1]:
|
||||
fn = cstr(fn[0]) + (fn[0] and ' ' or '') + cstr(fn[1])
|
||||
else:
|
||||
fn = webnotes.user.name
|
||||
|
||||
from webnotes.utils.email_lib import sendmail
|
||||
from setup.doctype.notification_control.notification_control import get_formatted_message
|
||||
|
||||
message = '''A new comment has been posted on your page by %s:
|
||||
|
||||
<b>Comment:</b> %s
|
||||
|
||||
To answer, please login to your erpnext account!
|
||||
''' % (fn, arg['comment'])
|
||||
|
||||
sendmail([arg['uid']], webnotes.user.name, get_formatted_message('New Comment', message), fn + ' has posted a new comment')
|
||||
|
||||
#
|
||||
# update read messages
|
||||
#
|
||||
def set_read_all_messages(arg=''):
|
||||
webnotes.conn.sql("""UPDATE `tabComment Widget Record`
|
||||
SET docstatus = 1
|
||||
WHERE comment_doctype = 'My Company'
|
||||
AND comment_docname = %s
|
||||
""", webnotes.user.name)
|
||||
|
||||
def update_security(args=''):
|
||||
import json
|
||||
args = json.loads(args)
|
||||
webnotes.conn.set_value('Profile', args['user'], 'restrict_ip', args.get('restrict_ip'))
|
||||
webnotes.conn.set_value('Profile', args['user'], 'login_after', args.get('login_after'))
|
||||
webnotes.conn.set_value('Profile', args['user'], 'login_before', args.get('login_before'))
|
||||
|
||||
if 'new_password' in args:
|
||||
if cint(webnotes.conn.get_value('Control Panel',None,'sync_with_gateway')):
|
||||
import server_tools.gateway_utils
|
||||
webnotes.msgprint(server_tools.gateway_utils.change_password('', args['new_password'])['message'])
|
||||
else:
|
||||
webnotes.conn.sql("update tabProfile set password=password(%s) where name=%s", (args['new_password'], args['user']))
|
||||
|
||||
webnotes.msgprint('Settings Updated')
|
||||
@@ -1,51 +0,0 @@
|
||||
# Page, My Company
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2010-12-14 10:23:19',
|
||||
'docstatus': 0,
|
||||
'modified': '2010-12-27 17:44:15',
|
||||
'modified_by': 'Administrator',
|
||||
'owner': 'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all Page
|
||||
{
|
||||
'doctype': 'Page',
|
||||
'module': 'Home',
|
||||
'name': '__common__',
|
||||
'page_name': 'My Company',
|
||||
'show_in_menu': 1,
|
||||
'standard': 'Yes'
|
||||
},
|
||||
|
||||
# These values are common for all Page Role
|
||||
{
|
||||
'doctype': 'Page Role',
|
||||
'name': '__common__',
|
||||
'parent': 'My Company',
|
||||
'parentfield': 'roles',
|
||||
'parenttype': 'Page'
|
||||
},
|
||||
|
||||
# Page, My Company
|
||||
{
|
||||
'doctype': 'Page',
|
||||
'name': 'My Company'
|
||||
},
|
||||
|
||||
# Page Role
|
||||
{
|
||||
'doctype': 'Page Role',
|
||||
'idx': 1,
|
||||
'role': 'Administrator'
|
||||
},
|
||||
|
||||
# Page Role
|
||||
{
|
||||
'doctype': 'Page Role',
|
||||
'idx': 2,
|
||||
'role': 'All'
|
||||
}
|
||||
]
|
||||
@@ -1,115 +0,0 @@
|
||||
pscript['onload_profile-settings'] = function() {
|
||||
var wrapper = page_body.pages['profile-settings'];
|
||||
wrapper.className = 'layout_wrapper';
|
||||
pscript.myprofile = new MyProfile(wrapper)
|
||||
}
|
||||
|
||||
MyProfile = function(wrapper) {
|
||||
this.wrapper = wrapper;
|
||||
var me = this;
|
||||
|
||||
this.make = function() {
|
||||
this.head = new PageHeader(this.wrapper, 'My Profile Settings');
|
||||
this.head.add_button('Change Password', this.change_password)
|
||||
this.tab = make_table($a(this.wrapper, 'div', '', {marginTop:'19px'}),
|
||||
1, 2, '90%', ['50%', '50%'], {padding:'11px'})
|
||||
this.img = $a($td(this.tab, 0, 0), 'img');
|
||||
set_user_img(this.img, user);
|
||||
|
||||
$btn($a($td(this.tab, 0, 0), 'div', '', {marginTop:'11px'}), 'Change Image', this.change_image)
|
||||
|
||||
this.make_form();
|
||||
this.load_details();
|
||||
}
|
||||
|
||||
this.load_details = function() {
|
||||
$c_page('home','profile_settings','get_user_details','',function(r, rt) {
|
||||
me.form.set_values(r.message);
|
||||
})
|
||||
}
|
||||
|
||||
//
|
||||
// form
|
||||
//
|
||||
this.make_form = function() {
|
||||
var div = $a($td(this.tab, 0, 1), 'div');
|
||||
this.form = new wn.widgets.FieldGroup()
|
||||
this.form.make_fields(div, [
|
||||
{fieldname:'first_name', fieldtype:'Data',label:'First Name',reqd:1},
|
||||
{fieldname:'last_name', fieldtype:'Data',label:'Last Name',reqd:1},
|
||||
{fieldname:'bio', fieldtype:'Text',label:'Bio'},
|
||||
{fieldname:'update', fieldtype:'Button',label:'Update'}
|
||||
]);
|
||||
|
||||
this.form.fields_dict.update.input.onclick = function() {
|
||||
var v = me.form.get_values();
|
||||
if(v) {
|
||||
this.set_working();
|
||||
var btn = this;
|
||||
$c_page('home','profile_settings','set_user_details',v,function(r, rt) {
|
||||
btn.done_working();
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// change password
|
||||
//
|
||||
this.change_password = function() {
|
||||
var d = new wn.widgets.Dialog({
|
||||
title:'Change Password',
|
||||
width: 400,
|
||||
fields: [
|
||||
{fieldname:'old_password', fieldtype:'Password', label:'Old Password', reqd:1 },
|
||||
{fieldname:'new_password', fieldtype:'Password', label:'New Password', reqd:1 },
|
||||
{fieldname:'new_password1', fieldtype:'Password', label:'Re-type New Password', reqd:1 },
|
||||
{fieldname:'change', fieldtype:'Button', label:'Change'}
|
||||
]
|
||||
})
|
||||
d.make();
|
||||
d.fields_dict.change.input.onclick = function() {
|
||||
var v = d.get_values();
|
||||
if(v) {
|
||||
if(v.new_password != v.new_password1) {
|
||||
msgprint('Passwords must match'); return;
|
||||
}
|
||||
this.set_working();
|
||||
$c_page('home','profile_settings','change_password',v,function(r,rt) {
|
||||
if(!r.message && r.exc) { msgprint(r.exc); return; }
|
||||
d.hide();
|
||||
})
|
||||
}
|
||||
}
|
||||
d.show();
|
||||
}
|
||||
|
||||
//
|
||||
// change image
|
||||
//
|
||||
|
||||
this.change_image = function() {
|
||||
if(!me.change_dialog) {
|
||||
|
||||
var d = new Dialog(400,200,'Set Your Profile Image');
|
||||
d.make_body([
|
||||
['HTML','wrapper']
|
||||
]);
|
||||
|
||||
var w = d.widgets['wrapper'];
|
||||
me.uploader = new Uploader(w, {cmd:'home.page.profile_settings.profile_settings.set_user_image'}, pscript.user_image_upload, 1)
|
||||
me.change_dialog = d;
|
||||
}
|
||||
me.change_dialog.show();
|
||||
}
|
||||
this.make();
|
||||
}
|
||||
|
||||
pscript.user_image_upload = function(fid) {
|
||||
msgprint('File Uploaded');
|
||||
|
||||
if(fid) {
|
||||
pscript.myprofile.change_dialog.hide();
|
||||
set_user_img(pscript.myprofile.img, user, null, fid);
|
||||
}
|
||||
}
|
||||
@@ -1,59 +0,0 @@
|
||||
import webnotes
|
||||
|
||||
from webnotes.utils import load_json, cint, nowdate
|
||||
|
||||
def change_password(arg):
|
||||
"""
|
||||
Change password
|
||||
"""
|
||||
arg = load_json(arg)
|
||||
|
||||
if cint(webnotes.conn.get_value('Control Panel',None,'sync_with_gateway')):
|
||||
import server_tools.gateway_utils
|
||||
webnotes.msgprint(server_tools.gateway_utils.change_password(arg['old_password'], arg['new_password'])['message'])
|
||||
else:
|
||||
if not webnotes.conn.sql('select name from tabProfile where name=%s and password=password(%s)', (webnotes.session['user'], arg['old_password'])):
|
||||
webnotes.msgprint('Old password is not correct', raise_exception=1)
|
||||
|
||||
from webnotes.utils import nowdate
|
||||
webnotes.conn.sql("update tabProfile set password=password(%s) where name=%s",(arg['new_password'], nowdate(), webnotes.session['user']))
|
||||
webnotes.msgprint('Password Updated');
|
||||
|
||||
def get_user_details(arg=None):
|
||||
"""
|
||||
Returns user first name, last name and bio
|
||||
"""
|
||||
return webnotes.conn.sql("select first_name, last_name, bio from tabProfile where name=%s", webnotes.user.name, as_dict=1)[0]
|
||||
|
||||
def set_user_details(arg=None):
|
||||
"""
|
||||
updates user details given in argument
|
||||
"""
|
||||
from webnotes.model.doc import Document
|
||||
|
||||
p = Document('Profile', webnotes.user.name)
|
||||
p.fields.update(load_json(arg))
|
||||
p.save()
|
||||
webnotes.msgprint('Updated')
|
||||
|
||||
def set_user_image(arg=None):
|
||||
"""
|
||||
Set uploaded image as user image
|
||||
"""
|
||||
from webnotes.utils.upload_handler import UploadHandler
|
||||
|
||||
uh = UploadHandler()
|
||||
if not uh.file_name:
|
||||
# do nothing - no file found
|
||||
return
|
||||
else:
|
||||
# save the file
|
||||
from webnotes.utils.file_manager import FileAttachments
|
||||
|
||||
fa = FileAttachments('Profile', webnotes.session['user'])
|
||||
fa.delete_all()
|
||||
fa.add(uh.file_name, uh.content)
|
||||
fa.save()
|
||||
|
||||
uh.set_callback('window.parent.upload_callback("%s", "%s")' \
|
||||
% (webnotes.form_dict['uploader_id'], fa.get_fid(0)))
|
||||
@@ -1,27 +0,0 @@
|
||||
# Page, profile-settings
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2011-04-18 10:19:10',
|
||||
'docstatus': 0,
|
||||
'modified': '2011-04-13 12:08:59',
|
||||
'modified_by': 'Administrator',
|
||||
'owner': 'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all Page
|
||||
{
|
||||
'doctype': 'Page',
|
||||
'module': 'Home',
|
||||
'name': '__common__',
|
||||
'page_name': 'Profile Settings',
|
||||
'standard': 'Yes'
|
||||
},
|
||||
|
||||
# Page, profile-settings
|
||||
{
|
||||
'doctype': 'Page',
|
||||
'name': 'profile-settings'
|
||||
}
|
||||
]
|
||||
@@ -1,34 +0,0 @@
|
||||
# Search Criteria, bills-to_be_paid
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2010-08-08 17:09:32',
|
||||
'docstatus': 0,
|
||||
'modified': '2010-05-13 17:26:48',
|
||||
'modified_by': 'Administrator',
|
||||
'owner': 'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all Search Criteria
|
||||
{
|
||||
'add_cond': '`tabPayable Voucher`.outstanding_amount!=0\n`tabPayable Voucher`.docstatus=1',
|
||||
'columns': 'Payable Voucher\x01ID,Payable Voucher\x01Voucher Date,Payable Voucher\x01Due Date,Payable Voucher\x01Credit To,Payable Voucher\x01Bill Date,Payable Voucher\x01Outstanding Amount',
|
||||
'criteria_name': 'Bills-To be paid',
|
||||
'doc_type': 'Payable Voucher',
|
||||
'doctype': 'Search Criteria',
|
||||
'filters': "{'Payable Voucher\x01Submitted':1,'Payable Voucher\x01Is Opening':'','Payable Voucher\x01Fiscal Year':''}",
|
||||
'module': 'Home',
|
||||
'name': '__common__',
|
||||
'page_len': 50,
|
||||
'sort_by': '`tabPayable Voucher`.`name`',
|
||||
'sort_order': 'DESC',
|
||||
'standard': 'Yes'
|
||||
},
|
||||
|
||||
# Search Criteria, bills-to_be_paid
|
||||
{
|
||||
'doctype': 'Search Criteria',
|
||||
'name': 'bills-to_be_paid'
|
||||
}
|
||||
]
|
||||
@@ -1,33 +0,0 @@
|
||||
# Search Criteria, bills-to_be_submitted
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2010-08-08 17:09:32',
|
||||
'docstatus': 0,
|
||||
'modified': '2010-05-03 12:24:43',
|
||||
'modified_by': 'Administrator',
|
||||
'owner': 'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all Search Criteria
|
||||
{
|
||||
'columns': 'Payable Voucher\x01ID,Payable Voucher\x01Voucher Date,Payable Voucher\x01Due Date,Payable Voucher\x01Credit To,Payable Voucher\x01Bill No,Payable Voucher\x01Bill Date,Payable Voucher\x01Outstanding Amount',
|
||||
'criteria_name': 'Bills-To be submitted',
|
||||
'doc_type': 'Payable Voucher',
|
||||
'doctype': 'Search Criteria',
|
||||
'filters': "{'Payable Voucher\x01Saved':1,'Payable Voucher\x01Is Opening':'','Payable Voucher\x01Fiscal Year':''}",
|
||||
'module': 'Home',
|
||||
'name': '__common__',
|
||||
'page_len': 50,
|
||||
'sort_by': '`tabPayable Voucher`.`name`',
|
||||
'sort_order': 'DESC',
|
||||
'standard': 'Yes'
|
||||
},
|
||||
|
||||
# Search Criteria, bills-to_be_submitted
|
||||
{
|
||||
'doctype': 'Search Criteria',
|
||||
'name': 'bills-to_be_submitted'
|
||||
}
|
||||
]
|
||||
@@ -1,34 +0,0 @@
|
||||
# Search Criteria, delivery_note-to_be_billed
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2010-08-08 17:09:32',
|
||||
'docstatus': 0,
|
||||
'modified': '2010-05-13 17:24:34',
|
||||
'modified_by': 'Administrator',
|
||||
'owner': 'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all Search Criteria
|
||||
{
|
||||
'add_cond': 'ifnull(`tabDelivery Note`.per_billed, 0) < 100',
|
||||
'columns': 'Delivery Note\x01ID,Delivery Note\x01Owner,Delivery Note\x01Customer Name,Delivery Note\x01% Billed,Delivery Note\x01Company',
|
||||
'criteria_name': 'Delivery Note-To be billed',
|
||||
'doc_type': 'Delivery Note',
|
||||
'doctype': 'Search Criteria',
|
||||
'filters': "{'Delivery Note\x01Submitted':1,'Delivery Note\x01Status':'Submitted','Delivery Note\x01Fiscal Year':''}",
|
||||
'module': 'Home',
|
||||
'name': '__common__',
|
||||
'page_len': 50,
|
||||
'sort_by': '`tabDelivery Note`.`name`',
|
||||
'sort_order': 'DESC',
|
||||
'standard': 'Yes'
|
||||
},
|
||||
|
||||
# Search Criteria, delivery_note-to_be_billed
|
||||
{
|
||||
'doctype': 'Search Criteria',
|
||||
'name': 'delivery_note-to_be_billed'
|
||||
}
|
||||
]
|
||||
@@ -1,33 +0,0 @@
|
||||
# Search Criteria, delivery_note-to_be_submitted
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2010-08-08 17:09:32',
|
||||
'docstatus': 0,
|
||||
'modified': '2010-05-13 17:17:58',
|
||||
'modified_by': 'Administrator',
|
||||
'owner': 'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all Search Criteria
|
||||
{
|
||||
'columns': 'Delivery Note\x01ID,Delivery Note\x01Owner,Delivery Note\x01Customer Name,Delivery Note\x01Posting Date,Delivery Note\x01Company',
|
||||
'criteria_name': 'Delivery Note-To be submitted',
|
||||
'doc_type': 'Delivery Note',
|
||||
'doctype': 'Search Criteria',
|
||||
'filters': "{'Delivery Note\x01Saved':1,'Delivery Note\x01Status':'Draft','Delivery Note\x01Fiscal Year':''}",
|
||||
'module': 'Home',
|
||||
'name': '__common__',
|
||||
'page_len': 50,
|
||||
'sort_by': '`tabDelivery Note`.`name`',
|
||||
'sort_order': 'DESC',
|
||||
'standard': 'Yes'
|
||||
},
|
||||
|
||||
# Search Criteria, delivery_note-to_be_submitted
|
||||
{
|
||||
'doctype': 'Search Criteria',
|
||||
'name': 'delivery_note-to_be_submitted'
|
||||
}
|
||||
]
|
||||
@@ -1,35 +0,0 @@
|
||||
# Search Criteria, enquiry-quotations_to_be_sent
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2010-08-08 17:09:31',
|
||||
'docstatus': 0,
|
||||
'modified': '2010-07-16 13:29:58',
|
||||
'modified_by': 'Administrator',
|
||||
'owner': 'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all Search Criteria
|
||||
{
|
||||
'add_cond': '`tabQuotation`.enq_no!=`tabEnquiry`.name\n',
|
||||
'add_tab': 'tabQuotation',
|
||||
'columns': 'Enquiry\x01ID,Enquiry\x01Owner',
|
||||
'criteria_name': 'Enquiry-Quotations to be sent',
|
||||
'doc_type': 'Enquiry',
|
||||
'doctype': 'Search Criteria',
|
||||
'filters': '{}',
|
||||
'module': 'Home',
|
||||
'name': '__common__',
|
||||
'page_len': 50,
|
||||
'sort_by': '`tabEnquiry`.`name`',
|
||||
'sort_order': 'DESC',
|
||||
'standard': 'Yes'
|
||||
},
|
||||
|
||||
# Search Criteria, enquiry-quotations_to_be_sent
|
||||
{
|
||||
'doctype': 'Search Criteria',
|
||||
'name': 'enquiry-quotations_to_be_sent'
|
||||
}
|
||||
]
|
||||
@@ -1,5 +0,0 @@
|
||||
report.customize_filters = function() {
|
||||
|
||||
this.filter_fields_dict['Enquiry'+FILTER_SEP +'Company'].df['report_default'] = sys_defaults.company;
|
||||
this.filter_fields_dict['Enquiry'+FILTER_SEP +'Fiscal Year'].df['report_default'] = sys_defaults.fiscal_year;
|
||||
}
|
||||
@@ -1,34 +0,0 @@
|
||||
# Search Criteria, enquiry-to_follow_up
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2010-09-01 15:48:09',
|
||||
'docstatus': 0,
|
||||
'modified': '2010-08-30 12:08:00',
|
||||
'modified_by': 'Administrator',
|
||||
'owner': 'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all Search Criteria
|
||||
{
|
||||
'add_cond': "`tabEnquiry`.name=`tabQuotation`.enq_no\n`tabEnquiry`.docstatus=1\n`tabQuotation`.status='Submitted'",
|
||||
'columns': 'Enquiry\x01ID,Enquiry\x01Owner,Enquiry\x01Company,Enquiry\x01Fiscal Year',
|
||||
'criteria_name': 'Enquiry-To follow up',
|
||||
'doc_type': 'Enquiry',
|
||||
'doctype': 'Search Criteria',
|
||||
'filters': "{'Enquiry\x01Fiscal Year':''}",
|
||||
'module': 'Home',
|
||||
'name': '__common__',
|
||||
'page_len': 50,
|
||||
'sort_by': '`tabEnquiry`.`name`',
|
||||
'sort_order': 'DESC',
|
||||
'standard': 'Yes'
|
||||
},
|
||||
|
||||
# Search Criteria, enquiry-to_follow_up
|
||||
{
|
||||
'doctype': 'Search Criteria',
|
||||
'name': 'enquiry-to_follow_up'
|
||||
}
|
||||
]
|
||||
@@ -1,34 +0,0 @@
|
||||
# Search Criteria, indent-purchase_order_to_be_made
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2010-08-08 17:09:32',
|
||||
'docstatus': 0,
|
||||
'modified': '2010-05-13 17:37:18',
|
||||
'modified_by': 'Administrator',
|
||||
'owner': 'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all Search Criteria
|
||||
{
|
||||
'add_cond': "`tabIndent`.status='Submitted'\nifnull(`tabIndent`.per_ordered,0)<100",
|
||||
'columns': 'Indent\x01ID,Indent\x01Indent Date,Indent\x01Requested By,Indent\x01Owner,Indent\x01% Ordered',
|
||||
'criteria_name': 'Indent-Purchase Order to be made',
|
||||
'doc_type': 'Indent',
|
||||
'doctype': 'Search Criteria',
|
||||
'filters': "{'Indent\x01Submitted':1,'Indent\x01Status':'Submitted','Indent\x01Fiscal Year':''}",
|
||||
'module': 'Home',
|
||||
'name': '__common__',
|
||||
'page_len': 50,
|
||||
'sort_by': '`tabIndent`.`name`',
|
||||
'sort_order': 'DESC',
|
||||
'standard': 'Yes'
|
||||
},
|
||||
|
||||
# Search Criteria, indent-purchase_order_to_be_made
|
||||
{
|
||||
'doctype': 'Search Criteria',
|
||||
'name': 'indent-purchase_order_to_be_made'
|
||||
}
|
||||
]
|
||||
@@ -1,34 +0,0 @@
|
||||
# Search Criteria, indent-to_be_submitted
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2010-08-08 17:09:32',
|
||||
'docstatus': 0,
|
||||
'modified': '2010-05-13 17:38:49',
|
||||
'modified_by': 'Administrator',
|
||||
'owner': 'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all Search Criteria
|
||||
{
|
||||
'add_cond': "`tabIndent`.status='Draft'",
|
||||
'columns': 'Indent\x01ID,Indent\x01Owner,Indent\x01Indent Date,Indent\x01Remarks',
|
||||
'criteria_name': 'Indent-To be submitted',
|
||||
'doc_type': 'Indent',
|
||||
'doctype': 'Search Criteria',
|
||||
'filters': "{'Indent\x01Saved':1,'Indent\x01Status':'Draft','Indent\x01Fiscal Year':''}",
|
||||
'module': 'Home',
|
||||
'name': '__common__',
|
||||
'page_len': 50,
|
||||
'sort_by': '`tabIndent`.`name`',
|
||||
'sort_order': 'DESC',
|
||||
'standard': 'Yes'
|
||||
},
|
||||
|
||||
# Search Criteria, indent-to_be_submitted
|
||||
{
|
||||
'doctype': 'Search Criteria',
|
||||
'name': 'indent-to_be_submitted'
|
||||
}
|
||||
]
|
||||
@@ -1,34 +0,0 @@
|
||||
# Search Criteria, invoices-overdue
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2010-08-08 17:09:31',
|
||||
'docstatus': 0,
|
||||
'modified': '2010-04-30 17:08:52',
|
||||
'modified_by': 'Administrator',
|
||||
'owner': 'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all Search Criteria
|
||||
{
|
||||
'add_cond': '`tabReceivable Voucher`.due_date<now()\n`tabReceivable Voucher`.outstanding_amount!=0\n`tabReceivable Voucher`.docstatus=1',
|
||||
'columns': 'Receivable Voucher\x01ID,Receivable Voucher\x01Debit To,Receivable Voucher\x01Voucher Date,Receivable Voucher\x01Due Date,Receivable Voucher\x01Outstanding Amount',
|
||||
'criteria_name': 'Invoices-Overdue',
|
||||
'doc_type': 'Receivable Voucher',
|
||||
'doctype': 'Search Criteria',
|
||||
'filters': "{'Receivable Voucher\x01Saved':1,'Receivable Voucher\x01Submitted':1,'Receivable Voucher\x01Is Opening':'','Receivable Voucher\x01Fiscal Year':''}",
|
||||
'module': 'Home',
|
||||
'name': '__common__',
|
||||
'page_len': 50,
|
||||
'sort_by': '`tabReceivable Voucher`.`name`',
|
||||
'sort_order': 'DESC',
|
||||
'standard': 'Yes'
|
||||
},
|
||||
|
||||
# Search Criteria, invoices-overdue
|
||||
{
|
||||
'doctype': 'Search Criteria',
|
||||
'name': 'invoices-overdue'
|
||||
}
|
||||
]
|
||||
@@ -1,33 +0,0 @@
|
||||
# Search Criteria, invoices-to_be_submitted
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2010-08-08 17:09:31',
|
||||
'docstatus': 0,
|
||||
'modified': '2010-05-03 10:18:56',
|
||||
'modified_by': 'Administrator',
|
||||
'owner': 'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all Search Criteria
|
||||
{
|
||||
'columns': 'Receivable Voucher\x01ID,Receivable Voucher\x01Debit To,Receivable Voucher\x01Voucher Date,Receivable Voucher\x01Due Date',
|
||||
'criteria_name': 'Invoices-To be submitted',
|
||||
'doc_type': 'Receivable Voucher',
|
||||
'doctype': 'Search Criteria',
|
||||
'filters': "{'Receivable Voucher\x01Saved':1,'Receivable Voucher\x01Is Opening':'','Receivable Voucher\x01Fiscal Year':''}",
|
||||
'module': 'Home',
|
||||
'name': '__common__',
|
||||
'page_len': 50,
|
||||
'sort_by': '`tabReceivable Voucher`.`name`',
|
||||
'sort_order': 'DESC',
|
||||
'standard': 'Yes'
|
||||
},
|
||||
|
||||
# Search Criteria, invoices-to_be_submitted
|
||||
{
|
||||
'doctype': 'Search Criteria',
|
||||
'name': 'invoices-to_be_submitted'
|
||||
}
|
||||
]
|
||||
@@ -1,34 +0,0 @@
|
||||
# Search Criteria, invoices-to_receive_payment
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2010-08-08 17:09:31',
|
||||
'docstatus': 0,
|
||||
'modified': '2010-04-30 16:54:26',
|
||||
'modified_by': 'Administrator',
|
||||
'owner': 'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all Search Criteria
|
||||
{
|
||||
'add_cond': '`tabReceivable Voucher`.due_date>now() \n`tabReceivable Voucher`.outstanding_amount!=0\n`tabReceivable Voucher`.docstatus=1',
|
||||
'columns': 'Receivable Voucher\x01ID,Receivable Voucher\x01Owner,Receivable Voucher\x01Debit To,Receivable Voucher\x01Voucher Date,Receivable Voucher\x01Due Date,Receivable Voucher\x01Outstanding Amount',
|
||||
'criteria_name': 'Invoices-To receive payment',
|
||||
'doc_type': 'Receivable Voucher',
|
||||
'doctype': 'Search Criteria',
|
||||
'filters': "{'Receivable Voucher\x01Submitted':1,'Receivable Voucher\x01Is Opening':'','Receivable Voucher\x01Fiscal Year':''}",
|
||||
'module': 'Home',
|
||||
'name': '__common__',
|
||||
'page_len': 50,
|
||||
'sort_by': '`tabReceivable Voucher`.`name`',
|
||||
'sort_order': 'DESC',
|
||||
'standard': 'Yes'
|
||||
},
|
||||
|
||||
# Search Criteria, invoices-to_receive_payment
|
||||
{
|
||||
'doctype': 'Search Criteria',
|
||||
'name': 'invoices-to_receive_payment'
|
||||
}
|
||||
]
|
||||
@@ -1,5 +0,0 @@
|
||||
report.customize_filters = function() {
|
||||
this.filter_fields_dict['Lead'+FILTER_SEP +'Status'].df.filter_hide = 1;
|
||||
this.filter_fields_dict['Lead'+FILTER_SEP +'Fiscal Year'].df['report_default'] = sys_defaults.fiscal_year;
|
||||
}
|
||||
|
||||
@@ -1,34 +0,0 @@
|
||||
# Search Criteria, lead-to_follow_up
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2010-09-01 15:48:09',
|
||||
'docstatus': 0,
|
||||
'modified': '2010-08-30 12:01:19',
|
||||
'modified_by': 'Administrator',
|
||||
'owner': 'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all Search Criteria
|
||||
{
|
||||
'add_cond': "`tabLead`.status!='Converted' \n`tabLead`.status!='Lead Lost' \n`tabLead`.status!='Not Interested'",
|
||||
'columns': 'Lead\x01ID,Lead\x01Status,Lead\x01Lead Name,Lead\x01Lead Date,Lead\x01Lead Owner,Lead\x01Next Contact Date',
|
||||
'criteria_name': 'Lead-To follow up',
|
||||
'doc_type': 'Lead',
|
||||
'doctype': 'Search Criteria',
|
||||
'filters': "{'Lead\x01Status':'','Lead\x01Source':'','Lead\x01Expected Month':'','Lead\x01Industry':'','Lead\x01Market Segment':'','Lead\x01Rating':''}",
|
||||
'module': 'Home',
|
||||
'name': '__common__',
|
||||
'page_len': 50,
|
||||
'sort_by': '`tabLead`.`name`',
|
||||
'sort_order': 'DESC',
|
||||
'standard': 'Yes'
|
||||
},
|
||||
|
||||
# Search Criteria, lead-to_follow_up
|
||||
{
|
||||
'doctype': 'Search Criteria',
|
||||
'name': 'lead-to_follow_up'
|
||||
}
|
||||
]
|
||||
@@ -1,11 +0,0 @@
|
||||
report.customize_filters = function() {
|
||||
this.hide_all_filters();
|
||||
this.filter_fields_dict['Sales Order'+FILTER_SEP +'Customer'].df.filter_hide = 0;
|
||||
this.filter_fields_dict['Sales Order'+FILTER_SEP +'ID'].df.filter_hide = 0;
|
||||
this.filter_fields_dict['Sales Order'+FILTER_SEP +'Quotation No'].df.filter_hide = 0;
|
||||
this.filter_fields_dict['Sales Order'+FILTER_SEP +'Company'].df.filter_hide = 0;
|
||||
this.filter_fields_dict['Sales Order'+FILTER_SEP +'Sales Partner'].df.filter_hide = 0;
|
||||
this.filter_fields_dict['Sales Order'+FILTER_SEP +'Fiscal Year'].df.filter_hide = 0;
|
||||
this.filter_fields_dict['Sales Order'+FILTER_SEP +'From Sales Order Date'].df.filter_hide = 0;
|
||||
this.filter_fields_dict['Sales Order'+FILTER_SEP +'To Sales Order Date'].df.filter_hide = 0;
|
||||
}
|
||||
@@ -1,34 +0,0 @@
|
||||
# Search Criteria, purchase_order-to_be_billed
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2010-08-08 17:09:32',
|
||||
'docstatus': 0,
|
||||
'modified': '2010-05-13 17:31:42',
|
||||
'modified_by': 'Administrator',
|
||||
'owner': 'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all Search Criteria
|
||||
{
|
||||
'add_cond': "ifnull(`tabPurchase Order`.per_billed,0)<100\n`tabPurchase Order`.status='Submitted'",
|
||||
'columns': 'Purchase Order\x01ID,Purchase Order\x01Supplier,Purchase Order\x01PO Date,Purchase Order\x01Company,Purchase Order\x01Grand Total',
|
||||
'criteria_name': 'Purchase Order-To be billed',
|
||||
'doc_type': 'Purchase Order',
|
||||
'doctype': 'Search Criteria',
|
||||
'filters': "{'Purchase Order\x01Submitted':1,'Purchase Order\x01Status':'Submitted','Purchase Order\x01Fiscal Year':''}",
|
||||
'module': 'Home',
|
||||
'name': '__common__',
|
||||
'page_len': 50,
|
||||
'sort_by': '`tabPurchase Order`.`name`',
|
||||
'sort_order': 'DESC',
|
||||
'standard': 'Yes'
|
||||
},
|
||||
|
||||
# Search Criteria, purchase_order-to_be_billed
|
||||
{
|
||||
'doctype': 'Search Criteria',
|
||||
'name': 'purchase_order-to_be_billed'
|
||||
}
|
||||
]
|
||||
@@ -1,33 +0,0 @@
|
||||
# Search Criteria, purchase_order-to_be_submitted
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2010-08-08 17:09:32',
|
||||
'docstatus': 0,
|
||||
'modified': '2010-05-03 11:19:23',
|
||||
'modified_by': 'Administrator',
|
||||
'owner': 'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all Search Criteria
|
||||
{
|
||||
'columns': 'Purchase Order\x01ID,Purchase Order\x01Supplier,Purchase Order\x01PO Date,Purchase Order\x01Company,Purchase Order\x01Grand Total',
|
||||
'criteria_name': 'Purchase Order-To be submitted',
|
||||
'doc_type': 'Purchase Order',
|
||||
'doctype': 'Search Criteria',
|
||||
'filters': "{'Purchase Order\x01Saved':1,'Purchase Order\x01Submitted':0,'Purchase Order\x01Status':'Draft','Purchase Order\x01Fiscal Year':''}",
|
||||
'module': 'Home',
|
||||
'name': '__common__',
|
||||
'page_len': 50,
|
||||
'sort_by': '`tabPurchase Order`.`name`',
|
||||
'sort_order': 'DESC',
|
||||
'standard': 'Yes'
|
||||
},
|
||||
|
||||
# Search Criteria, purchase_order-to_be_submitted
|
||||
{
|
||||
'doctype': 'Search Criteria',
|
||||
'name': 'purchase_order-to_be_submitted'
|
||||
}
|
||||
]
|
||||
@@ -1,34 +0,0 @@
|
||||
# Search Criteria, purchase_order-to_receive_items
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2010-08-08 17:09:32',
|
||||
'docstatus': 0,
|
||||
'modified': '2010-05-13 17:34:22',
|
||||
'modified_by': 'Administrator',
|
||||
'owner': 'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all Search Criteria
|
||||
{
|
||||
'add_cond': "ifnull(`tabPurchase Order`.per_received,0)<100\n`tabPurchase Order`.status='Submitted'",
|
||||
'columns': 'Purchase Order\x01ID,Purchase Order\x01Supplier,Purchase Order\x01PO Date,Purchase Order\x01Company,Purchase Order\x01% Received,Purchase Order\x01Grand Total',
|
||||
'criteria_name': 'Purchase Order-To receive items',
|
||||
'doc_type': 'Purchase Order',
|
||||
'doctype': 'Search Criteria',
|
||||
'filters': "{'Purchase Order\x01Submitted':1,'Purchase Order\x01Status':'Submitted','Purchase Order\x01Fiscal Year':''}",
|
||||
'module': 'Home',
|
||||
'name': '__common__',
|
||||
'page_len': 50,
|
||||
'sort_by': '`tabPurchase Order`.`name`',
|
||||
'sort_order': 'DESC',
|
||||
'standard': 'Yes'
|
||||
},
|
||||
|
||||
# Search Criteria, purchase_order-to_receive_items
|
||||
{
|
||||
'doctype': 'Search Criteria',
|
||||
'name': 'purchase_order-to_receive_items'
|
||||
}
|
||||
]
|
||||
@@ -1,34 +0,0 @@
|
||||
# Search Criteria, sales_order-overdue
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2010-08-26 11:52:28',
|
||||
'docstatus': 0,
|
||||
'modified': '2010-08-26 11:52:09',
|
||||
'modified_by': 'Administrator',
|
||||
'owner': 'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all Search Criteria
|
||||
{
|
||||
'add_cond': '`tabSales Order`.delivery_date<now()\nifnull(`tabSales Order`.per_delivered,0)<100',
|
||||
'columns': 'Sales Order\x01ID,Sales Order\x01Customer,Sales Order\x01Sales Order Date,Sales Order\x01Expected Delivery Date,Sales Order\x01Quotation No,Sales Order\x01Company,Sales Order\x01% Delivered',
|
||||
'criteria_name': 'Sales Order-Overdue',
|
||||
'doc_type': 'Sales Order',
|
||||
'doctype': 'Search Criteria',
|
||||
'filters': "{'Sales Order\x01Submitted':1,'Sales Order\x01Status':'Submitted','Sales Order\x01Fiscal Year':''}",
|
||||
'module': 'Home',
|
||||
'name': '__common__',
|
||||
'page_len': 50,
|
||||
'sort_by': '`tabSales Order`.`name`',
|
||||
'sort_order': 'DESC',
|
||||
'standard': 'Yes'
|
||||
},
|
||||
|
||||
# Search Criteria, sales_order-overdue
|
||||
{
|
||||
'doctype': 'Search Criteria',
|
||||
'name': 'sales_order-overdue'
|
||||
}
|
||||
]
|
||||
@@ -1,34 +0,0 @@
|
||||
# Search Criteria, sales_order-to_be_billed
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2010-08-08 17:09:31',
|
||||
'docstatus': 0,
|
||||
'modified': '2010-05-13 17:45:37',
|
||||
'modified_by': 'Administrator',
|
||||
'owner': 'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all Search Criteria
|
||||
{
|
||||
'add_cond': "ifnull(`tabSales Order`.per_billed,0)<100\n`tabSales Order`.status='Submitted'",
|
||||
'columns': 'Sales Order\x01ID,Sales Order\x01Status,Sales Order\x01Quotation No,Sales Order\x01Sales Order Date,Sales Order\x01Expected Delivery Date,Sales Order\x01% Billed,Sales Order\x01Customer',
|
||||
'criteria_name': 'Sales Order-To be billed',
|
||||
'doc_type': 'Sales Order',
|
||||
'doctype': 'Search Criteria',
|
||||
'filters': "{'Sales Order\x01Submitted':1,'Sales Order\x01Fiscal Year':''}",
|
||||
'module': 'Home',
|
||||
'name': '__common__',
|
||||
'page_len': 50,
|
||||
'sort_by': '`tabSales Order`.`name`',
|
||||
'sort_order': 'DESC',
|
||||
'standard': 'Yes'
|
||||
},
|
||||
|
||||
# Search Criteria, sales_order-to_be_billed
|
||||
{
|
||||
'doctype': 'Search Criteria',
|
||||
'name': 'sales_order-to_be_billed'
|
||||
}
|
||||
]
|
||||
@@ -1,34 +0,0 @@
|
||||
# Search Criteria, sales_order-to_be_delivered
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2010-08-08 17:09:31',
|
||||
'docstatus': 0,
|
||||
'modified': '2010-05-13 17:53:29',
|
||||
'modified_by': 'Administrator',
|
||||
'owner': 'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all Search Criteria
|
||||
{
|
||||
'add_cond': "ifnull(`tabSales Order`.per_delivered,0)<100\n`tabSales Order`.status = 'Submitted'\n`tabSales Order`. delivery_date > now()",
|
||||
'columns': 'Sales Order\x01ID,Sales Order\x01Owner,Sales Order\x01Status,Sales Order\x01Customer,Sales Order\x01Sales Order Date,Sales Order\x01Expected Delivery Date,Sales Order\x01Quotation No',
|
||||
'criteria_name': 'Sales Order-To be delivered',
|
||||
'doc_type': 'Sales Order',
|
||||
'doctype': 'Search Criteria',
|
||||
'filters': "{'Sales Order\x01Saved':1,'Sales Order\x01Submitted':1,'Sales Order\x01Fiscal Year':''}",
|
||||
'module': 'Home',
|
||||
'name': '__common__',
|
||||
'page_len': 100,
|
||||
'sort_by': '`tabSales Order`.`name`',
|
||||
'sort_order': 'DESC',
|
||||
'standard': 'Yes'
|
||||
},
|
||||
|
||||
# Search Criteria, sales_order-to_be_delivered
|
||||
{
|
||||
'doctype': 'Search Criteria',
|
||||
'name': 'sales_order-to_be_delivered'
|
||||
}
|
||||
]
|
||||
@@ -1,34 +0,0 @@
|
||||
# Search Criteria, sales_order-to_be_submitted
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2010-08-08 17:09:31',
|
||||
'docstatus': 0,
|
||||
'modified': '2010-05-13 17:47:45',
|
||||
'modified_by': 'Administrator',
|
||||
'owner': 'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all Search Criteria
|
||||
{
|
||||
'add_cond': "`tabSales Order`.status='Draft'",
|
||||
'columns': 'Sales Order\x01ID,Sales Order\x01Customer,Sales Order\x01Sales Order Date,Sales Order\x01Quotation No',
|
||||
'criteria_name': 'Sales Order-To be submitted',
|
||||
'doc_type': 'Sales Order',
|
||||
'doctype': 'Search Criteria',
|
||||
'filters': "{'Sales Order\x01Saved':1,'Sales Order\x01Fiscal Year':''}",
|
||||
'module': 'Home',
|
||||
'name': '__common__',
|
||||
'page_len': 100,
|
||||
'sort_by': '`tabSales Order`.`name`',
|
||||
'sort_order': 'DESC',
|
||||
'standard': 'Yes'
|
||||
},
|
||||
|
||||
# Search Criteria, sales_order-to_be_submitted
|
||||
{
|
||||
'doctype': 'Search Criteria',
|
||||
'name': 'sales_order-to_be_submitted'
|
||||
}
|
||||
]
|
||||
@@ -1,34 +0,0 @@
|
||||
# Search Criteria, serial_no-amc_expiring_this_month
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2010-08-08 17:09:32',
|
||||
'docstatus': 0,
|
||||
'modified': '2010-07-29 15:01:33',
|
||||
'modified_by': 'Administrator',
|
||||
'owner': 'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all Search Criteria
|
||||
{
|
||||
'add_cond': '`tab Serial No`.month(amc_expiry_date)=month(now()) \n`tab Serial No`.year(amc_expiry_date)=year(now())',
|
||||
'columns': 'Serial No\x01ID,Serial No\x01Status,Serial No\x01AMC Expiry Date,Serial No\x01Customer Name',
|
||||
'criteria_name': 'Serial No-AMC expiring this month',
|
||||
'doc_type': 'Serial No',
|
||||
'doctype': 'Search Criteria',
|
||||
'filters': "{'Serial No\x01Saved':1,'Serial No\x01Submitted':1,'Serial No\x01Status':'','Serial No\x01Warranty Status':''}",
|
||||
'module': 'Home',
|
||||
'name': '__common__',
|
||||
'page_len': 50,
|
||||
'sort_by': '`tabSerial No`.`name`',
|
||||
'sort_order': 'DESC',
|
||||
'standard': 'Yes'
|
||||
},
|
||||
|
||||
# Search Criteria, serial_no-amc_expiring_this_month
|
||||
{
|
||||
'doctype': 'Search Criteria',
|
||||
'name': 'serial_no-amc_expiring_this_month'
|
||||
}
|
||||
]
|
||||
@@ -1,34 +0,0 @@
|
||||
# Search Criteria, serial_no-warranty_expiring_this_month
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2010-08-08 17:09:32',
|
||||
'docstatus': 0,
|
||||
'modified': '2010-07-23 09:57:51',
|
||||
'modified_by': 'Administrator',
|
||||
'owner': 'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all Search Criteria
|
||||
{
|
||||
'add_cond': "`tab Serial No`.docstatus!=2\n`tab Serial No`.maintenance_status='Under Warranty'\n`tab Serial No`.status!='Scrapped'\n`tab Serial No`.status!='Not in Use'\n`tab Serial No`.month(ifnull(warranty_expiry_date,0)) = month(now()) \n`tab Serial No`.yearmonth(ifnull(warranty_expiry_date,0)) = year(now())",
|
||||
'columns': 'Serial No\x01ID,Serial No\x01Status,Serial No\x01Warranty Expiry Date,Serial No\x01Customer Name',
|
||||
'criteria_name': 'Serial No-Warranty expiring this month',
|
||||
'doc_type': 'Serial No',
|
||||
'doctype': 'Search Criteria',
|
||||
'filters': "{'Serial No\x01Saved':1,'Serial No\x01Submitted':1,'Serial No\x01Status':'Issued','Serial No\x01Maintenance Status':''}",
|
||||
'module': 'Home',
|
||||
'name': '__common__',
|
||||
'page_len': 50,
|
||||
'sort_by': '`tabSerial No`.`name`',
|
||||
'sort_order': 'DESC',
|
||||
'standard': 'Yes'
|
||||
},
|
||||
|
||||
# Search Criteria, serial_no-warranty_expiring_this_month
|
||||
{
|
||||
'doctype': 'Search Criteria',
|
||||
'name': 'serial_no-warranty_expiring_this_month'
|
||||
}
|
||||
]
|
||||
@@ -1,34 +0,0 @@
|
||||
# Search Criteria, task-open
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2010-08-08 17:09:32',
|
||||
'docstatus': 0,
|
||||
'modified': '2010-07-16 13:03:49',
|
||||
'modified_by': 'Administrator',
|
||||
'owner': 'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all Search Criteria
|
||||
{
|
||||
'add_cond': "`tabTicket`.status='Open'",
|
||||
'columns': 'Ticket\x01ID,Ticket\x01Subject,Ticket\x01Priority,Ticket\x01Raised By,Ticket\x01Allocated To',
|
||||
'criteria_name': 'Task-Open',
|
||||
'doc_type': 'Ticket',
|
||||
'doctype': 'Search Criteria',
|
||||
'filters': "{'Ticket\x01Priority':''}",
|
||||
'module': 'Home',
|
||||
'name': '__common__',
|
||||
'page_len': 50,
|
||||
'sort_by': '`tabTicket`.`name`',
|
||||
'sort_order': 'DESC',
|
||||
'standard': 'Yes'
|
||||
},
|
||||
|
||||
# Search Criteria, task-open
|
||||
{
|
||||
'doctype': 'Search Criteria',
|
||||
'name': 'task-open'
|
||||
}
|
||||
]
|
||||
Reference in New Issue
Block a user