moved directory structure

This commit is contained in:
Rushabh Mehta
2012-09-24 19:13:42 +05:30
parent e47a6779e9
commit 2fa2f7178d
1637 changed files with 47 additions and 11450 deletions

1
home/page/__init__.py Normal file
View File

@@ -0,0 +1 @@
from __future__ import unicode_literals

View File

@@ -0,0 +1 @@
from __future__ import unicode_literals

View File

@@ -0,0 +1,23 @@
#activity-list .label {
display: inline-block;
width: 100px;
margin-right: 7px;
}
#activity-list .label-info {
cursor: pointer;
}
#activity-list .user-info {
float: right;
color: #777;
font-size: 10px;
}
#activity-list .date-sep {
margin-bottom: 11px;
padding: 5px 0px;
border-bottom: 1px solid #aaa;
color: #555;
font-size: 10px;
}

View File

@@ -0,0 +1,7 @@
<div class="layout-wrapper layout-wrapper-appframe">
<div class="layout-appframe"></div>
<div class="layout-main">
<div id="activity-list">
</div>
</div>
</div>

View File

@@ -0,0 +1,67 @@
wn.pages['activity'].onload = function(wrapper) {
wrapper.appframe = new wn.ui.AppFrame($(wrapper).find('.layout-appframe'));
wrapper.appframe.title('Activity');
var list = new wn.ui.Listing({
appframe: wrapper.appframe,
method: 'home.page.activity.activity.get_feed',
parent: $('#activity-list'),
render_row: function(row, data) {
new erpnext.ActivityFeed(row, data);
}
});
list.run();
}
erpnext.last_feed_date = false;
erpnext.ActivityFeed = Class.extend({
init: function(row, data) {
this.scrub_data(data);
this.add_date_separator(row, data);
$(row).append(sprintf('<div style="margin: 0px">\
<span class="avatar-small"><img src="%(imgsrc)s" /></span> \
<span %(onclick)s class="label %(add_class)s">%(feed_type)s</span>\
%(link)s %(subject)s <span class="user-info">%(by)s</span></div>', data));
},
scrub_data: function(data) {
data.by = wn.user_info(data.owner).fullname;
data.imgsrc = wn.user_info(data.owner).image;
// feedtype
if(!data.feed_type) {
data.feed_type = get_doctype_label(data.doc_type);
data.add_class = "label-info";
data.onclick = repl('onclick="window.location.href=\'#!List/%(feed_type)s\';"', data)
}
// color for comment
if(data.feed_type=='Comment') {
data.add_class = "label-important";
}
if(data.feed_type=='Assignment') {
data.add_class = "label-warning";
}
// link
if(data.doc_name && data.feed_type!='Login') {
data.link = repl('<a href="#!Form/%(doc_type)s/%(doc_name)s">%(doc_name)s</a>', data)
}
},
add_date_separator: function(row, data) {
var date = dateutil.str_to_obj(data.modified);
var last = erpnext.last_feed_date;
if((last && dateutil.obj_to_str(last) != dateutil.obj_to_str(date)) || (!last)) {
var diff = dateutil.get_day_diff(new Date(), date);
if(diff < 1) {
pdate = 'Today';
} else if(diff < 2) {
pdate = 'Yesterday';
} else {
pdate = dateutil.global_date_format(date);
}
$(row).html(repl('<div class="date-sep">%(date)s</div>', {date: pdate}));
}
erpnext.last_feed_date = date;
}
})

View File

@@ -0,0 +1,17 @@
from __future__ import unicode_literals
import webnotes
@webnotes.whitelist()
def get_feed(arg=None):
"""get feed"""
return webnotes.conn.sql("""select
distinct t1.name, t1.feed_type, t1.doc_type, t1.doc_name, t1.subject, t1.owner,
t1.modified
from tabFeed t1, tabDocPerm t2
where t1.doc_type = t2.parent
and t2.role in ('%s')
and ifnull(t2.`read`,0) = 1
order by t1.modified desc
limit %s, %s""" % ("','".join(webnotes.get_roles()),
webnotes.form_dict['limit_start'], webnotes.form_dict['limit_page_length']),
as_dict=1)

View File

@@ -0,0 +1,28 @@
# Page, activity
[
# These values are common in all dictionaries
{
'creation': '2012-02-29 11:59:13',
'docstatus': 0,
'modified': '2012-02-29 12:11:46',
'modified_by': u'Administrator',
'owner': u'Administrator'
},
# These values are common for all Page
{
'doctype': 'Page',
'module': u'Home',
'name': '__common__',
'page_name': u'activity',
'standard': u'Yes',
'title': u'Activity'
},
# Page, activity
{
'doctype': 'Page',
'name': u'activity'
}
]

View File

@@ -0,0 +1 @@
from __future__ import unicode_literals

View File

View File

@@ -0,0 +1,93 @@
<div class="layout-wrapper">
<a class="close" onclick="window.history.back();">&times;</a>
<h1>Attributions</h1>
<hr>
<p><b>Source Code:</b> <a href="https://github.com/webnotes/erpnext">
https://github.com/webnotes/erpnext</a></p>
<p><b>Website:</b> <a href="https://erpnext.com">
https://erpnext.com</a></p>
<hr>
<p class="help">ERPNext is an Open Source project and is possible because of the work of
thousands of software developers, companies and designers who have contributed their
work to the community. We have tried to list as many projects as possible that are
used by ERPNext, but this list may not be exhaustive.</p>
<h4>Server</h4>
<ul>
<li>Linux (GNU)</li>
<li>Apache HTTPD server (web server)</li>
<li>MySQL (database, Percona build)</li>
<li>Git (source code control via Github)</li>
</ul>
<h4>Programming Languages & Libraries</h4>
<ul>
<li><a href="http://python.org">Python</a></li>
<ul>
<li>Python-MySQL</li>
<li>pytz (timezones)</li>
<li>jinja2 (templating)</li>
<li>markdown2 (markdown parser)</li>
<li>jsmin (javascript minifier)</li>
</ul>
<li>Javascript</li>
<ul>
<li>JQuery</li>
<li>JQuery UI (datepicker, sortable)</li>
<li>TinyMCE - text editor</li>
<li>Twitter Bootstrap</li>
<li>Ace - code editor</li>
<li>Slick Grid - report grid</li>
<li>jQPlot - graphs</li>
<li><a href="http://taitems.github.com/jQuery.Gantt/">JQuery.Gantt</a> - Gantt Chart</li>
<li>JSON2 - JSON builder, parser</li>
<li>JSColor - color picker</li>
<li><a href="https://github.com/dcneiner/Downloadify">Downloadify</a> - Export CSV files from the browser</li>
</ul>
</ul>
<h4>CSS Frameworks</h4>
<ul>
<li>Twitter Bootstrap</li>
</ul>
<h4>Icons</h4>
<ul>
<li>The Noun Project</li>
<li>Glyphicons</li>
</ul>
<h4>Web Frameworks</h4>
<ul>
<li>wnframework</li>
</ul>
<h4>Web Browsers</h4>
<ul>
<li>Mozilla Firefox</li>
<ul>
<li>Firebug (debugger)</li>
</ul>
<li>Apple Safari</li>
<li>Google Chorme</li>
</ul>
<hr>
<h2>ERPNext License</h2>
<p><b>ERPNext - Open Source, web based ERP</b></p>
<p>Copyright &copy; 2008 onwards, Web Notes Technologies Pvt Ltd, India</p>
<p>This program is free software: you can redistribute it and/or modify
it under the terms of the <b>GNU General Public License</b> as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.</p>
<p>This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.</p>
<p>For complete license see <a href="http://www.gnu.org/licenses/">http://www.gnu.org/licenses/</a></p>
<hr>
<p>For more information please write to us at support@erpnext.com</p>
</div>

View File

@@ -0,0 +1 @@
wn.pages['attributions'].onload = function(wrapper) { }

View File

@@ -0,0 +1,2 @@
from __future__ import unicode_literals
import webnotes

View File

@@ -0,0 +1,28 @@
# Page, attributions
[
# These values are common in all dictionaries
{
'creation': '2012-03-01 12:30:42',
'docstatus': 0,
'modified': '2012-03-01 12:30:42',
'modified_by': u'Administrator',
'owner': u'Administrator'
},
# These values are common for all Page
{
'doctype': 'Page',
'module': u'Home',
'name': '__common__',
'page_name': u'attributions',
'standard': u'Yes',
'title': u'Attributions'
},
# Page, attributions
{
'doctype': 'Page',
'name': u'attributions'
}
]

View File

@@ -0,0 +1 @@
from __future__ import unicode_literals

View File

@@ -0,0 +1,12 @@
div.dashboard_table td {
width: 50%;
}
div.dashboard-title {
font-weight: bold;
padding: '3px 0px';
}
div.dashboard-graph {
height: 180px;
}

View File

@@ -0,0 +1,8 @@
<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>

View File

@@ -0,0 +1,170 @@
// ERPNext - web based ERP (http://erpnext.com)
// Copyright (C) 2012 Web Notes Technologies Pvt Ltd
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
pscript.onload_dashboard = function() {
// load jqplot
wn.require('lib/js/lib/jqplot/css/jqplot.css');
wn.require('lib/js/lib/jqplot/jquery.jqplot.min.js');
wn.require('lib/js/lib/jqplot/jqplot-plugins/jqplot.barRenderer.js');
wn.require('lib/js/lib/jqplot/jqplot-plugins/jqplot.canvasAxisTickRenderer.min.js');
wn.require('lib/js/lib/jqplot/jqplot-plugins/jqplot.canvasTextRenderer.min.js');
wn.require('lib/js/lib/jqplot/jqplot-plugins/jqplot.categoryAxisRenderer.min.js');
pscript.dashboard_settings = {
company: sys_defaults.company,
start: (function() {
var start_date = dateutil.add_days(new Date(), -180);
var year_start_date = dateutil.str_to_obj(sys_defaults.year_start_date);
if (start_date < year_start_date) { start_date = year_start_date; }
console.log(start_date);
return dateutil.obj_to_str(start_date);
})(),
end: (function() {
var end_date = new Date();
var year_end_date = dateutil.str_to_obj(sys_defaults.year_end_date);
if (end_date > year_end_date) { end_date = year_end_date; }
console.log(end_date);
return dateutil.obj_to_str(end_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();
}
})
}

View File

@@ -0,0 +1,286 @@
# ERPNext - web based ERP (http://erpnext.com)
# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from __future__ import unicode_literals
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'
}
]
import webnotes
class DashboardWidget:
def __init__(self, company, start, end, interval):
from webnotes.utils import getdate
from webnotes.model.code import get_obj
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
fiscal_year = self.get_fiscal_year(start)
if fiscal_year:
return self.glc.get_as_on_balance(acc, fiscal_year, start, debit_or_credit, lft, rgt)
else:
webnotes.msgprint('Please select the START DATE and END DATE such that\
they fall within <b>fiscal year(s)</b> as defined in\
Setup > System > Fiscal Year.', raise_exception=1)
def get_fiscal_year(self, dt):
"""
get fiscal year from date
"""
import webnotes
fiscal_year = 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))
return fiscal_year and (fiscal_year[0] and fiscal_year[0][0]) or None
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)
@webnotes.whitelist()
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"
}""")

View File

@@ -0,0 +1,49 @@
# 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'
}
]

View File

@@ -0,0 +1 @@
from __future__ import unicode_literals

View File

@@ -0,0 +1,119 @@
/* Sprite CSS */
.sprite-account{ background-position: 0 0; width: 32px; height: 40px; }
.sprite-buying{ background-position: 0 -90px; width: 40px; height: 40px; }
.sprite-calendar{ background-position: 0 -180px; width: 35px; height: 40px; }
.sprite-dashboard{ background-position: 0 -270px; width: 40px; height: 29px; }
.sprite-feed{ background-position: 0 -349px; width: 32px; height: 40px; }
.sprite-hr{ background-position: 0 -439px; width: 40px; height: 32px; }
.sprite-kb{ background-position: 0 -521px; width: 24px; height: 39px; }
.sprite-messages{ background-position: 0 -610px; width: 40px; height: 26px; }
.sprite-production{ background-position: 0 -686px; width: 40px; height: 33px; }
.sprite-project{ background-position: 0 -769px; width: 40px; height: 22px; }
.sprite-report{ background-position: 0 -841px; width: 29px; height: 40px; }
.sprite-selling{ background-position: 0 -931px; width: 34px; height: 40px; }
.sprite-setting{ background-position: 0 -1021px; width: 37px; height: 40px; }
.sprite-stock{ background-position: 0 -1111px; width: 34px; height: 39px; }
.sprite-support{ background-position: 0 -1200px; width: 40px; height: 40px; }
.sprite-todo{ background-position: 0 -1290px; width: 40px; height: 34px; }
.sprite-website{ background-position: 0 -1374px; width: 40px; height: 40px; }
.sprite-image { background-image: url("images/sprite-desktop.png"); }
.sprite-account{ margin-top: 8px; margin-left: 12px; }
.sprite-selling{ margin-top: 8px; margin-left: 12px; }
.sprite-stock{ margin-top: 8px; margin-left: 8px; }
.sprite-buying{ margin-top: 8px; margin-left: 8px; }
.sprite-support{ margin-top: 8px; margin-left: 8px; }
.sprite-hr{ margin-top: 12px; margin-left: 8px; }
.sprite-project{ margin-top: 16px; margin-left: 8px; }
.sprite-production{ margin-top: 10px; margin-left: 8px; }
.sprite-website{ margin-top: 8px; margin-left: 8px; }
.sprite-setting{ margin-top: 8px; margin-left: 8px; }
.sprite-dashboard{ margin-top: 14px; margin-left: 8px; }
.sprite-report{ margin-top: 8px; margin-left: 14px; }
.sprite-messages{ margin-top: 14px; margin-left: 8px; }
.sprite-todo{ margin-top: 10px; margin-left: 10px; }
.sprite-calendar{ margin-top: 8px; margin-left: 10px; }
.sprite-kb{ margin-top: 8px; margin-left: 16px; }
.sprite-feed{ margin-top: 8px; margin-left: 14px; }
.case-border {
border-radius: 10px;
-moz-border-radius: 10px;
-webkit-border-radius: 10px;
width: 56px;
height: 56px;
border: 4px solid white;
box-shadow: 0 0 4px 1px black;
-moz-box-shadow: 0 0 4px 1px black;
-webkit-box-shadow: 0 0 4px 1px black;
-o-box-shadow: 0 0 4px 1px black;
margin: auto;
}
.case-wrapper {
margin: 24px;
float: left;
width: 100px;
height: 100px;
}
.case-label {
color: white;
padding-top: 10px;
text-align: center;
text-shadow: 1px 1px 2px #000, 1px 1px 2px #000, 1px 1px 2px #000, 0px 0px 2px #000;
}
/* Hover and click effects */
.case-border:hover, .circle:hover, .hover-effect {
box-shadow: 0 0 2px 0px black, 0 0 4px 1px white !important;
-moz-box-shadow: 0 0 2px 0px black, 0 0 4px 1px white !important;
-webkit-box-shadow: 0 0 2px 0px black, 0 0 4px 1px white !important;
-o-box-shadow: 0 0 2px 0px black, 0 0 10px 1px white !important;
}
.case-border:active, .case-border:focus, .case-border-click {
transform: scale(0.98, 0.98);
-ms-transform: scale(0.98, 0.98); /* IE 9 */
-webkit-transform: scale(0.98, 0.98); /* Safari and Chrome */
-o-transform: scale(0.98, 0.98); /* Opera */
-moz-transform: scale(0.98, 0.98); /* Firefox */
}
.circle:active, .circle:focus, .circle-click {
transform: scale(1, 1);
-ms-transform: scale(1, 1); /* IE 9 */
-webkit-transform: scale(1, 1); /* Safari and Chrome */
-o-transform: scale(1, 1); /* Opera */
-moz-transform: scale(1, 1); /* Firefox */
}
.circle {
border-radius: 30px;
-moz-border-radius: 30px;
-webkit-border-radius: 30px;
height: 15px;
line-height: 12px;
min-width: 15px;
background: #B00D07;
padding: 3px;
float: right;
margin-top: -74px;
margin-right: 10px;
border: 2px solid white;
box-shadow: 0 0 4px 1px black;
-moz-box-shadow: 0 0 4px 1px black;
-webkit-box-shadow: 0 0 4px 1px black;
-o-box-shadow: 0 0 4px 1px black;
}
.circle-text {
color: white;
text-align: center;
display: inline-block;
margin-top: 1px;
}

View File

@@ -0,0 +1,6 @@
<div style="min-height: 500px; background: None; text-align: center;
margin: 0px auto;">
<div id="icon-grid">
</div>
</div>
<div style="clear: both"></div>

View File

@@ -0,0 +1,139 @@
wn.provide('erpnext.desktop');
erpnext.desktop.gradient = "<style>\
.case-%(name)s {\
background: %(start)s; /* Old browsers */\
background: -moz-radial-gradient(center, ellipse cover, %(start)s 0%, %(middle)s 44%, %(end)s 100%); /* FF3.6+ */\
background: -webkit-gradient(radial, center center, 0px, center center, 100%, color-stop(0%,%(start)s), color-stop(44%,%(middle)s), color-stop(100%,%(end)s)); /* Chrome,Safari4+ */\
background: -webkit-radial-gradient(center, ellipse cover, %(start)s 0%,%(middle)s 44%,%(end)s 100%); /* Chrome10+,Safari5.1+ */\
background: -o-radial-gradient(center, ellipse cover, %(start)s 0%,%(middle)s 44%,%(end)s 100%); /* Opera 12+ */\
background: -ms-radial-gradient(center, ellipse cover, %(start)s 0%,%(middle)s 44%,%(end)s 100%); /* IE10+ */\
background: radial-gradient(center, ellipse cover, %(start)s 0%,%(middle)s 44%,%(end)s 100%); /* W3C */\
}\
</style>"
erpnext.desktop.refresh = function() {
erpnext.desktop.add_classes();
erpnext.desktop.render();
}
erpnext.desktop.add_classes = function() {
var classes = [
{ name: 'red', start: '#A90329', middle: '#8F0222', end: '#6D0019' },
{ name: 'brown', start: '#723e02', middle: '#633501', end: '#4a2700' },
{ name: 'green', start: '#4b5602', middle: '#3f4901', end: '#313800' },
{ name: 'blue', start: '#026584', middle: '#025770', end: '#004256' },
{ name: 'yellow', start: '#be7902', middle: '#a66a02', end: '#865500' },
{ name: 'purple', start: '#4d017d', middle: '#410169', end: '#310050' },
{ name: 'ocean', start: '#02a47e', middle: '#018d6c', end: '#006a51' },
{ name: 'pink', start: '#a40281', middle: '#8d016e', end: '#6a0053' },
{ name: 'grey', start: '#545454', middle: '#484848', end: '#363636' },
{ name: 'dark-red', start: '#68021a', middle: '#590116', end: '#440010' },
{ name: 'leaf-green', start: '#b0a400', middle: '#968c00', end: '#726a00' },
//{ name: 'dark-blue', start: '#023bae', middle: '#013295', end: '#002672' },
{ name: 'bright-green', start: '#03ad1f', middle: '#02941a', end: '#007213' },
{ name: 'bright-yellow', start: '#ffd65e', middle: '#febf04', end: '#ed9017' },
{ name: 'peacock', start: '#026584', middle: '#026584', end: '#322476' },
{ name: 'violet', start: '#50448e', middle: '#473b7f', end: '#3a3169' },
{ name: 'ultra-dark-green', start: '#014333', middle: '#01372b', end: '#002a20' },
];
$.each(classes, function(i, v) {
$(repl(erpnext.desktop.gradient, v)).appendTo('head');
});
}
erpnext.desktop.render = function() {
var icons = {
'Accounts': { gradient: 'blue', sprite: 'account', label: 'Accounts'},
'Selling': { gradient: 'green', sprite: 'selling', label: 'Selling'},
'Stock': { gradient: 'yellow', sprite: 'stock', label: 'Stock'},
'Buying': { gradient: 'red', sprite: 'buying', label: 'Buying'},
'Support': { gradient: 'purple', sprite: 'support', label: 'Support'},
'HR': { gradient: 'ocean', sprite: 'hr', label: 'Human<br />Resources'},
'Projects': { gradient: 'violet', sprite: 'project', label: 'Projects'},
'Production': { gradient: 'dark-red', sprite: 'production', label: 'Production'},
'Website': { gradient: 'leaf-green', sprite: 'website', label: 'Website'},
'Activity': { gradient: 'brown', sprite: 'feed', label: 'Activity'},
'Setup': { gradient: 'grey', sprite: 'setting', label: 'Setup'},
'Dashboard': { gradient: 'bright-green', sprite: 'dashboard', label: 'Dashboard'},
'To Do': { gradient: 'bright-yellow', sprite: 'todo', label: 'To Do'},
'Messages': { gradient: 'pink', sprite: 'messages', label: 'Messages'},
'Calendar': { gradient: 'peacock', sprite: 'calendar', label: 'Calendar'},
'Knowledge Base': { gradient: 'ultra-dark-green', sprite: 'kb', label: 'Knowledge<br />Base'}
}
var add_icon = function(m) {
var icon = icons[m];
icon.link = erpnext.modules[m];
$('#icon-grid').append(repl('\
<div id="%(sprite)s" class="case-wrapper"><a href="#!%(link)s">\
<div class="case-border case-%(gradient)s">\
<div class="sprite-image sprite-%(sprite)s"></div>\
</div></a>\
<div class="case-label">%(label)s</div>\
</div>', icon));
}
// setup
for(var i in wn.boot.modules_list) {
var m = wn.boot.modules_list[i];
if(!in_list(['Setup', 'Dashboard'], m) && wn.boot.profile.allow_modules.indexOf(m)!=-1)
add_icon(m);
}
if(user_roles.indexOf('Accounts Manager')!=-1)
add_icon('Dashboard')
if(user_roles.indexOf('System Manager')!=-1)
add_icon('Setup')
// apps
erpnext.desktop.show_pending_notifications();
}
erpnext.desktop.show_pending_notifications = function() {
var add_circle = function(str_module, id, title) {
var module = $('#'+str_module);
module.find('a:first').append(
repl('<div id="%(id)s" class="circle" title="%(title)s" style="display: None">\
<span class="circle-text"></span>\
</div>', {id: id, title: title}));
var case_border = module.find('.case-border');
var circle = module.find('.circle');
var add_hover_and_click = function(primary, secondary, hover_class, click_class) {
primary
.hover(
function() { secondary.addClass(hover_class); },
function() { secondary.removeClass(hover_class); })
.mousedown(function() { secondary.addClass(click_class); })
.mouseup(function() { secondary.removeClass(click_class); })
.focusin(function() { $(this).mousedown(); })
.focusout(function() { $(this).mouseup(); })
}
add_hover_and_click(case_border, circle, 'hover-effect', 'circle-click');
add_hover_and_click(circle, case_border, 'hover-effect', 'case-border-click');
}
add_circle('messages', 'unread_messages', 'Unread Messages');
add_circle('support', 'open_support_tickets', 'Open Support Tickets');
add_circle('todo', 'things_todo', 'Things To Do');
add_circle('calendar', 'todays_events', 'Todays Events');
add_circle('project', 'open_tasks', 'Open Tasks');
add_circle('kb', 'unanswered_questions', 'Unanswered Questions');
erpnext.update_messages();
}
pscript.onload_desktop = function() {
// load desktop
erpnext.desktop.refresh();
}

View File

@@ -0,0 +1,28 @@
# Page, desktop
[
# These values are common in all dictionaries
{
'creation': '2012-02-24 11:37:43',
'docstatus': 0,
'modified': '2012-02-24 11:37:43',
'modified_by': u'Administrator',
'owner': u'Administrator'
},
# These values are common for all Page
{
'doctype': 'Page',
'module': u'Home',
'name': '__common__',
'page_name': u'desktop',
'standard': u'Yes',
'title': u'Desktop'
},
# Page, desktop
{
'doctype': 'Page',
'name': u'desktop'
}
]

View File

@@ -0,0 +1 @@
from __future__ import unicode_literals

View File

@@ -0,0 +1,5 @@
<div class="layout-wrapper layout-wrapper-appframe">
<div class="layout-appframe"></div>
<div class="layout-main">
</div>
</div>

View File

@@ -0,0 +1,149 @@
// ERPNext - web based ERP (http://erpnext.com)
// Copyright (C) 2012 Web Notes Technologies Pvt Ltd
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
pscript['onload_profile-settings'] = function() {
var wrapper = wn.pages['profile-settings'];
pscript.myprofile = new MyProfile(wrapper)
}
MyProfile = function(wrapper) {
this.wrapper = wrapper;
var me = this;
this.make = function() {
this.wrapper.appframe = new wn.ui.AppFrame($(this.wrapper).find('.layout-appframe'), 'Profile Settings');
this.wrapper.appframe.add_button('Change Password', this.change_password);
this.wrapper.appframe.add_button('Change Background', this.change_background);
this.tab = make_table($a($(this.wrapper).find('.layout-main').get(0), 'div', '', {marginTop:'19px'}),
1, 2, '90%', ['50%', '50%'], {padding:'11px'})
this.img = $a($td(this.tab, 0, 0), 'img', '', {width: '120px', maxHeight:'200px'});
this.img.src = wn.user_info(user).image;
$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'},
{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() {
var d = new wn.widgets.Dialog({
title: 'Set your Profile'
});
wn.upload.make({
parent: d.body,
args: {
method: 'home.page.profile_settings.profile_settings.set_user_image'
},
callback: function(fid) {
if(fid) {
d.hide();
wn.boot.user_info[user].image = 'files/' + fid;
pscript.myprofile.img.src = 'files/' + fid;
}
}
});
d.show();
}
this.change_background = function() {
var d = new wn.widgets.Dialog({
title: 'Set Background Image'
})
wn.upload.make({
parent: d.body,
args: {
method: 'home.page.profile_settings.profile_settings.set_user_background'
},
callback: function(fid) {
if(fid) {
d.hide();
erpnext.set_user_background(fid);
}
}
});
d.show();
}
this.make();
}

View File

@@ -0,0 +1,112 @@
# ERPNext - web based ERP (http://erpnext.com)
# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from __future__ import unicode_literals
import webnotes
from webnotes.utils import load_json, cint, nowdate
def check_demo():
demo_user = 'demo@webnotestech.com'
if webnotes.session['user']==demo_user:
webnotes.msgprint("Can't change in demo", raise_exception=1)
@webnotes.whitelist()
def change_password(arg):
"""
Change password
"""
check_demo()
arg = load_json(arg)
if not webnotes.conn.sql("""select * from `__Auth` where `user`=%s
and password=password(%s)""",
(webnotes.session["user"], arg["old_password"])):
webnotes.msgprint('Old password is not correct', raise_exception=1)
webnotes.conn.sql("""update `__Auth` set password=password(%s)
where `user`=%s""", (arg["new_password"], webnotes.session["user"]))
webnotes.msgprint('Password Updated');
@webnotes.whitelist()
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]
@webnotes.whitelist()
def set_user_details(arg=None):
"""
updates user details given in argument
"""
check_demo()
from webnotes.model.doc import Document
p = Document('Profile', webnotes.user.name)
arg_dict = load_json(arg)
if not 'bio' in arg_dict: arg_dict['bio'] = None
if not 'last_name' in arg_dict: arg_dict['last_name'] = None
p.fields.update(arg_dict)
p.save()
webnotes.msgprint('Updated')
@webnotes.whitelist()
def set_user_image():
"""
Set uploaded image as user image
"""
check_demo()
from webnotes.utils.file_manager import add_file_list, remove_file, save_uploaded
user = webnotes.session['user']
fid, fname = save_uploaded()
# remove old file
old_image = webnotes.conn.get_value('Profile', user, 'user_image')
if old_image:
remove_file('Profile', user, old_image)
# add new file
add_file_list('Profile', user, fname, fid)
webnotes.conn.set_value('Profile', user, 'user_image', fid)
return fid
@webnotes.whitelist()
def set_user_background():
"""
Set uploaded image as user image
"""
check_demo()
from webnotes.utils.file_manager import add_file_list, remove_file, save_uploaded
user = webnotes.session['user']
fid, fname = save_uploaded()
# remove old file
old_image = webnotes.conn.get_value('Profile', user, 'background_image')
if old_image:
remove_file('Profile', user, old_image)
# add new file
add_file_list('Profile', user, fname, fid)
webnotes.conn.set_value('Profile', user, 'background_image', fid)
return fid

View File

@@ -0,0 +1,27 @@
# 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'
}
]