fixes after sync

This commit is contained in:
Anand Doshi 2012-04-06 17:54:17 +05:30
parent 7e0479bc4c
commit 82042f1cff
42 changed files with 245 additions and 2144 deletions

View File

@ -1732,6 +1732,7 @@ div.stat-bar {
font-weight: 400;
src: local('Open Sans'), local('OpenSans'), url('../lib/css/fonts/opensans.woff') format('woff');
}
@font-face {
font-family: 'Lato';
font-style: normal;
@ -1739,6 +1740,12 @@ div.stat-bar {
src: local('Lato Regular'), local('Lato-Regular'), url('../lib/css/fonts/lato.woff') format('woff');
}
@font-face {
font-family: 'Cabin';
font-style: normal;
font-weight: 400;
src: local('Cabin Regular'), local('Cabin-Regular'), url('../lib/css/fonts/cabin.woff') format('woff');
}
/*

View File

@ -1627,6 +1627,7 @@ button.btn.small, input[type="submit"].btn.small {
font-weight: 400;
src: local('Open Sans'), local('OpenSans'), url('../lib/css/fonts/opensans.woff') format('woff');
}
@font-face {
font-family: 'Lato';
font-style: normal;
@ -1634,6 +1635,12 @@ button.btn.small, input[type="submit"].btn.small {
src: local('Lato Regular'), local('Lato-Regular'), url('../lib/css/fonts/lato.woff') format('woff');
}
@font-face {
font-family: 'Cabin';
font-style: normal;
font-weight: 400;
src: local('Cabin Regular'), local('Cabin-Regular'), url('../lib/css/fonts/cabin.woff') format('woff');
}
/*

View File

@ -17,7 +17,7 @@
cur_frm.cscript.tname = "Purchase Invoice Item";
cur_frm.cscript.fname = "entries";
cur_frm.cscript.other_fname = "purchase_tax_details";
wn.require('erpnext/buying/doctype/purchase_other_charges/purchase_other_charges.js');
wn.require('erpnext/accounts/doctype/purchase_taxes_and_charges_master/purchase_taxes_and_charges_master.js');
wn.require('erpnext/buying/doctype/purchase_common/purchase_common.js');
// On Load

View File

@ -19,7 +19,7 @@
'default_print_format': u'Standard',
'doctype': 'DocType',
'document_type': u'Master',
'module': u'Buying',
'module': u'Accounts',
'name': '__common__',
'section_style': u'Simple',
'server_code_error': u' ',

View File

@ -23,7 +23,7 @@ cur_frm.cscript.sales_team_fname = "sales_team";
cur_frm.pformat.print_heading = 'Invoice';
wn.require('erpnext/selling/doctype/sales_common/sales_common.js');
wn.require('erpnext/setup/doctype/other_charges/other_charges.js');
wn.require('erpnext/accounts/doctype/sales_taxes_and_charges_master/sales_taxes_and_charges_master.js');
wn.require('erpnext/utilities/doctype/sms_control/sms_control.js');
wn.require('erpnext/setup/doctype/notification_control/notification_control.js');

View File

@ -19,7 +19,7 @@
'default_print_format': u'Standard',
'doctype': 'DocType',
'document_type': u'Master',
'module': u'Setup',
'module': u'Accounts',
'name': '__common__',
'section_style': u'Tabbed',
'server_code_error': u' ',

View File

@ -18,7 +18,7 @@ cur_frm.cscript.tname = "Purchase Order Item";
cur_frm.cscript.fname = "po_details";
cur_frm.cscript.other_fname = "purchase_tax_details";
wn.require('erpnext/buying/doctype/purchase_other_charges/purchase_other_charges.js');
wn.require('erpnext/accounts/doctype/purchase_taxes_and_charges_master/purchase_taxes_and_charges_master.js');
wn.require('erpnext/buying/doctype/purchase_common/purchase_common.js');
wn.require('erpnext/utilities/doctype/sms_control/sms_control.js');
wn.require('erpnext/setup/doctype/notification_control/notification_control.js');

Binary file not shown.

View File

@ -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;
}

View File

@ -1 +0,0 @@
<div id="updates_div"></div>

View File

@ -1,671 +0,0 @@
// 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_Event Updates'] = function() {
if(user=='Guest') {
loadpage('Login Page');
return;
}
pscript.home_make_body();
pscript.home_make_status();
pscript.home_set_banner();
pscript.home_make_widgets();
}
// ==================================
pscript.home_make_body = function() {
var wrapper = wn.pages['Event Updates'];
// body
$(wrapper).addClass('layout-wrapper').addClass('layout-wrapper-background')
wrapper.body = $a(wrapper, 'div', 'layout-main-section');
wrapper.head = $a(wrapper.body, 'div');
wrapper.side_section =$a(wrapper, 'div', 'layout-side-section');
$a(wrapper, 'div', '', {clear:'both'});
wrapper.banner_area = $a(wrapper.head, 'div');
wrapper.setup_wizard_area = $a(wrapper.body, 'div', 'setup-wizard');
}
// ==================================
pscript.home_set_banner = function(wrapper) {
var wrapper = wn.pages['Event Updates'];
var cp = wn.control_panel;
// banner
if(cp.client_name) {
var banner = $a(wrapper.banner_area, 'div', '', {paddingBottom:'4px'})
banner.innerHTML = cp.client_name;
}
}
// Widgets
// ==================================
pscript.home_make_widgets = function() {
var wrapper = wn.pages['Event Updates'];
var cell = wrapper.side_section;
// 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);
}
}
]
});
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)
me.wrapper.innerHTML = "";
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()},null,'cupid-blue');
// 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.name; }
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.priority=='Low' ? '#888' :
(det.priority=='High' ? '#EDA857' : '#687FD3'))});
$(span).css('-moz-border-radius','3px').css('-webkit-border-radius','3px');
span.innerHTML = det.priority;
// text
var span = $a($td(tab, 0, 1), 'div', 'social', {lineHeight:'1.5em'},
replace_newlines(det.description));
if(det.checked) $y(span,{textDecoration:'line-through'});
// reference link
if(det.reference_name) {
$a($td(tab, 0, 1), 'div', 'social', '',
repl('<a href="#!Form/%(reference_type)s/%(reference_name)s">%(reference_name)s</a>',
det))
}
// if expired & open, then in red
if(!det.checked && dateutil.str_to_obj(det.date) < new Date()) {
$y(span,{color:'RED'});
$a($td(tab, 0, 1), 'div', '', {fontSize:'10px', color:'#666'},
dateutil.str_to_user(det.date) + ' (Overdue)');
} else {
$a($td(tab, 0, 1), 'div', '', {fontSize:'10px', color:'#666'},
dateutil.str_to_user(det.date));
}
}
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.date,
priority: det.priority,
description: det.description,
checked: det.checked
});
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.name;
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');
// refresh
$a(this.head,'span','link_type',
{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'}, 'cupid-blue')
}
}
FeedList.prototype.run = function() {
this.prev_date = null;
this.list.run();
}
FeedList.prototype.make_list = function() {
var me = this;
this.list_area = $a(this.wrapper,'div')
this.list = new wn.ui.Listing({
parent: this.list_area,
query: repl('select \
distinct t1.name, t1.feed_type, t1.doc_type, t1.doc_name, t1.subject, t1.modified_by, \
if(ifnull(t1.full_name,"")="", t1.owner, t1.full_name) as full_name, \
t1.modified, t1.color \
from tabFeed t1, tabUserRole t3, tabDocPerm t4 \
where t1.doc_type = t4.parent \
and t3.parent = "%(user)s" \
and t4.role = t3.role \
and ifnull(t4.`read`,0) = 1 \
order by t1.modified desc', {user:user}),
no_result_message: 'Nothing to show yet. Your feed will be updated as you start your activities',
render_row: function(parent, data) {
me.render_feed(parent, data)
},
onrun: function() {
$(me.wrapper).fadeIn();
if(me.after_run) me.after_run();
},
hide_refresh: true
});
}
FeedList.prototype.render_feed = function(parent, data) {
new FeedItem(parent, data, 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'})
$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.modified.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.modified, 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) {
// type is the name
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.color || '#273')});
// tag label
tag.innerHTML = det.feed_type || get_doctype_label(det.doc_type);
// not comment / label
if(!det.feed_type) {
tag.dt = det.doc_type;
tag.onclick = function() { loaddocbrowser(this.dt); }
}
}
FeedItem.prototype.render_references = function(div, det) {
// name
div.tab = make_table(div, 1, 2, '100%', [null, '15%'])
var dt = det.doc_type; var dn = det.doc_name
// link
if(det.feed_type=='Login') {
// nothing - no link
} else {
var allow = in_list(profile.can_read, dt);
var span = $a($td(div.tab,0,0), 'span', (allow ? 'link_type': ''), null,
det.doc_name);
span.dt = dt; span.dn = dn;
if(allow) span.onclick = function() { loaddoc(this.dt, this.dn); }
}
// subject
if(det.subject) {
$a($td(div.tab,0,0), 'span', '', {marginLeft:'7px', color:'#444'}, det.subject);
}
// by
$y($td(div.tab,0,1), {fontSize:'11px'}).innerHTML =
(strip(det.full_name) ? det.full_name : det.modified_by);
}
pscript.home_make_status = function() {
var wrapper = wn.pages['Event Updates'];
// get values
$c_page('home', 'event_updates', 'get_status_details', user,
function(r,rt) {
//wn.container.wntoolbar.set_new_comments(r.message.unread_messages);
// render online users
pscript.online_users_obj.render(r.message.online_users);
pscript.online_users = r.message.online_users;
// complete registration
if(in_list(user_roles,'System Manager')) {
wn.require("erpnext/home/page/event_updates/complete_registration.js");
pscript.complete_registration(r.message.registration_complete, r.message.profile);
}
// setup wizard
if(r.message.setup_status) {
new SetupWizard(r.message.setup_status)
}
}
);
}
SetupWizard = function(status) {
var me = this;
$.extend(this, {
make: function(status) {
me.status = status;
me.wrapper = wn.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);
}

View File

@ -1,152 +0,0 @@
# 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/>.
import webnotes
from webnotes.utils import cint
@webnotes.whitelist()
def get_online_users(arg=None):
# 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 []
def get_unread_messages():
"returns unread (docstatus-0 messages for a user)"
return webnotes.conn.sql("""\
SELECT name, comment
FROM `tabComment`
WHERE comment_doctype IN ('My Company', 'Message')
AND comment_docname = %s
AND ifnull(docstatus,0)=0
""", webnotes.user.name, as_list=1)
def get_open_support_tickets():
"""
Returns a count of open support tickets
"""
from webnotes.utils import cint
open_support_tickets = webnotes.conn.sql("""\
SELECT COUNT(*) FROM `tabSupport Ticket`
WHERE status = 'Open'""")
return open_support_tickets and cint(open_support_tickets[0][0]) or 0
def get_things_todo():
"""
Returns a count of incomplete todos
"""
from webnotes.utils import cint
incomplete_todos = webnotes.conn.sql("""\
SELECT COUNT(*) FROM `tabToDo`
WHERE IFNULL(checked, 0) = 0
AND owner = %s""", webnotes.session.get('user'))
return incomplete_todos and cint(incomplete_todos[0][0]) or 0
def get_todays_events():
"""
Returns a count of todays events in calendar
"""
from webnotes.utils import nowdate, cint
todays_events = webnotes.conn.sql("""\
SELECT COUNT(*) FROM `tabEvent`
WHERE owner = %s
AND event_type != 'Cancel'
AND event_date = %s""", (
webnotes.session.get('user'), nowdate()))
return todays_events and cint(todays_events[0][0]) or 0
@webnotes.whitelist()
def get_global_status_messages(arg=None):
return {
'unread_messages': get_unread_messages(),
'open_support_tickets': get_open_support_tickets(),
'things_todo': get_things_todo(),
'todays_events': get_todays_events(),
}
@webnotes.whitelist()
def get_status_details(arg=None):
"""get toolbar items"""
from webnotes.utils import cint, date_diff, nowdate, get_defaults
online = get_online_users()
# system messages
ret = {
'user_count': len(online) or 0,
#'unread_messages': get_unread_messages(),
#'open_support_tickets': get_open_support_tickets(),
'online_users': online or [],
'setup_status': get_setup_status(),
'registration_complete': cint(get_defaults('registration_complete')) and 'Yes' or 'No',
'profile': webnotes.conn.sql("""\
SELECT first_name, last_name FROM `tabProfile`
WHERE name=%s AND docstatus<2""", webnotes.user.name, as_dict=1)
}
return ret
def get_setup_status(arg=None):
"""
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') or '')):
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}

View File

@ -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'
}
]

View File

@ -1 +0,0 @@
Event Updates

View File

@ -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;
}

View File

@ -1,760 +0,0 @@
// 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_My Company'] = function() {
var wrapper = wn.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 fields = [{
fieldtype: 'Data',
fieldname: 'user',
reqd: 1,
label: 'Email Id of the user to add'
},
{
fieldtype: 'Data',
fieldname: 'first_name',
reqd: 1,
label: 'First Name'
},
{
fieldtype: 'Data',
fieldname: 'last_name',
label: 'Last Name'
},
{
fieldtype: 'Data',
fieldname: 'password',
reqd: 1,
label: 'Password'
},
{
fieldtype: 'Button',
label: 'Add',
fieldname: 'add'
}];
fields.push();
var d = new wn.widgets.Dialog({
title: 'Add User',
width: 400,
fields: fields
});
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() {
wn.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 wn.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.ui.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 = 'lib/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 sd = 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'
}
]
});
me.sec_dialog = sd
sd.onshow = function() {
me.sec_dialog.set_values({
restrict_ip: me.profile.restrict_ip || '',
login_before: me.profile.login_before || '',
login_after: me.profile.login_after || '',
new_password: ''
});
};
sd.fields_dict.update.input.onclick = function() {
var btn = this;
this.set_working();
var args = me.sec_dialog.get_values();
args.user = me.profile.name;
if (args.new_password) {
var pass_d = new wn.widgets.Dialog({
title: 'Your Password',
width: 300,
fields: [
{
label: 'Please Enter <b style="color: black">Your Password</b>',
description: "Your password is required to update the concerned user's password",
fieldtype: 'Password',
fieldname: 'sys_admin_pwd',
reqd: 1
},
{
label: 'Continue',
fieldtype: 'Button',
fieldname: 'continue'
}
]
});
pass_d.fields_dict.continue.input.onclick = function() {
btn.pwd_dialog.hide();
args.sys_admin_pwd = btn.pwd_dialog.get_values().sys_admin_pwd;
btn.set_working();
me.update_security(args);
btn.done_working();
}
pass_d.show();
btn.pwd_dialog = pass_d;
btn.done_working();
} else {
btn.done_working();
me.update_security(args);
}
};
sd.show();
}
this.update_security = function(args) {
$c_page('home', 'my_company', 'update_security', JSON.stringify(args), function(r,rt) {
if(r.exc) {
msgprint(r.exc);
return;
}
me.sec_dialog.hide();
$.extend(me.profile, me.sec_dialog.get_values());
});
}
// delete user
// create a confirm dialog and call server method
this.delete_user = function() {
var cp = wn.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.load.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');
// 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.disabled = true;
this.input.onkeyup = this.input.onchange = function() {
if(this.value) {
me.post.disabled = false;
} else {
me.post.disabled = true;
}
}
// 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.ui.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` "+
"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` "+
"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() {
wn.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));
}

View File

@ -1,218 +0,0 @@
# 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/>.
import webnotes
from webnotes.utils import cint, load_json, cstr
from webnotes.model.doc import Document
try: import json
except: import simplejson as json
@webnotes.whitelist()
def get_account_settings_url(arg=''):
import server_tools.gateway_utils
return server_tools.gateway_utils.get_account_settings_url()
@webnotes.whitelist()
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])
}
@webnotes.whitelist()
def enable_profile(arg=''):
webnotes.conn.sql("update tabProfile set enabled=1 where name=%s", arg)
return 1
@webnotes.whitelist()
def disable_profile(arg=''):
if arg=='Administrator':
return 'Cannot disable Administrator'
webnotes.conn.sql("update tabProfile set enabled=0 where name=%s", arg)
webnotes.login_manager.logout(user=arg)
return 0
@webnotes.whitelist()
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
import webnotes.defs
from webnotes.utils import cint
if hasattr(webnotes.defs, 'sync_with_gateway') and \
cint(webnotes.defs.sync_with_gateway) or 0:
from server_tools.gateway_utils import remove_user_gateway
remove_user_gateway(args['user'])
webnotes.login_manager.logout(user=args['user'])
@webnotes.whitelist()
def add_user(args):
args = json.loads(args)
# erpnext-saas
import webnotes.defs
from webnotes.utils import cint
if hasattr(webnotes.defs, 'sync_with_gateway') and \
cint(webnotes.defs.sync_with_gateway) or 0:
from server_tools.gateway_utils import add_user_gateway
add_user_gateway(args)
add_profile(args)
@webnotes.whitelist()
def add_profile(args):
from webnotes.utils import validate_email_add, now
email = args['user']
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 with new password')
else:
# does not exist, create it!
pr = Document('Profile')
pr.name = email
pr.email = email
pr.first_name = args.get('first_name')
pr.last_name = args.get('last_name')
pr.enabled = 1
pr.user_type = 'System User'
pr.save(1)
if args.get('password'):
sql("""
UPDATE tabProfile
SET password = PASSWORD(%s), modified = %s
WHERE name = %s""", (args.get('password'), now, email))
send_welcome_mail(email, args)
@webnotes.whitelist()
def send_welcome_mail(email, args):
"""send welcome mail to user with password and login url"""
pr = Document('Profile', email)
from webnotes.utils.email_lib import sendmail_md
args.update({
'company': webnotes.conn.get_default('company'),
'password': args.get('password'),
'account_url': webnotes.conn.get_default('account_url')
})
if not args.get('last_name'): args['last_name'] = ''
sendmail_md(pr.email, subject="Welcome to ERPNext", msg=welcome_txt % args, from_defs=1)
#
# post comment
#
@webnotes.whitelist()
def post_comment(arg):
arg = load_json(arg)
from webnotes.model.doc import Document
d = Document('Comment')
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.get('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
message = '''A new comment has been posted on your page by %s:
<b>Comment:</b> %s
To answer, please login to your erpnext account!
<a href='https://signin.erpnext.com'>https://signin.erpnext.com</a>
''' % (fn, arg['comment'])
from webnotes.model.code import get_obj
note = get_obj('Notification Control')
email_msg = note.prepare_message({
'type': 'New Comment',
'message': message
})
sender = webnotes.user.name!='Administrator' and webnotes.user.name or 'support+admin_post@erpnext.com'
from webnotes.utils.email_lib import sendmail
sendmail([arg['uid']], sender, email_msg, fn + ' has posted a new comment')
#
# update read messages
#
@webnotes.whitelist()
def set_read_all_messages(arg=''):
webnotes.conn.sql("""UPDATE `tabComment`
SET docstatus = 1
WHERE comment_doctype = 'My Company'
AND comment_docname = %s
""", webnotes.user.name)
@webnotes.whitelist()
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:
import webnotes.defs
from webnotes.utils import cint
if hasattr(webnotes.defs, 'sync_with_gateway') and \
cint(webnotes.defs.sync_with_gateway) or 0:
import server_tools.gateway_utils
res = server_tools.gateway_utils.change_password('', args['new_password'], args['user'], args['sys_admin_pwd'])
if 'Traceback' not in res['message']:
webnotes.msgprint(res['message'])
webnotes.conn.sql("update tabProfile set password=password(%s) where name=%s", (args['new_password'], args['user']))
else: webnotes.msgprint('Settings Updated')
welcome_txt = """
## %(company)s
Dear %(first_name)s %(last_name)s
Welcome!
A new account has been created for you, here are your details:
login-id: %(user)s
password: %(password)s
To login to your new ERPNext account, please go to:
%(account_url)s
"""

View File

@ -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'
}
]

View File

@ -17,6 +17,7 @@
import webnotes
from webnotes.utils import load_json, cint, cstr
import json
# add a new question
@webnotes.whitelist()
@ -30,14 +31,14 @@ def add_question(arg):
d.save(1)
if args['suggest']:
from home.page.my_company.my_company import post_comment
from utilities.page.messages import messages
for s in args['suggest']:
if s:
post_comment({
'uid': s,
'comment': 'Please help me and answer the question "%s" in the Knowledge Base' % d.question,
messages.post(json.dumps({
'contact': s,
'txt': 'Please help me and answer the question "%s" in the Knowledge Base' % d.question,
'notify': 1
})
}))
@webnotes.whitelist()
def vote(arg):

View File

@ -14,8 +14,6 @@ def execute1():
replace_labels_with_fieldnames()
def execute():
# delete dt, mapper
delete_dt_and_mapper()
#---------------------------------------------------
# doctype renaming
@ -45,9 +43,52 @@ def execute():
#---------------------------------------------------
# Reload mapper from file
for d in ren_mapper:
mod = '_'.join(webnotes.conn.sql("select module from `tabDocType Mapper` where name = %s", ren_mapper[d])[0][0].lower().split())
mod = '_'.join(webnotes.conn.sql("select module from `tabDocType Mapper` where name = %s",
ren_mapper[d])[0][0].lower().split())
reload_doc(mod, 'DocType Mapper', ren_mapper[d])
delete_search_criteria()
# reload custom search criteria
#for d in webnotes.conn.sql("""select name, module from
# `tabSearch Criteria` where ifnull(standard, 'No') = 'Yes' and ifnull(disabled, 0) = 0"""):
#
for path, folders, files in os.walk(webnotes.defs.modules_path):
if not path.endswith('search_criteria'): continue
module = path.split(os.sep)[-2]
for sc in folders:
try:
reload_doc(module, 'search_criteria', sc)
print module, sc
except Exception, e:
print "did not reload: " + str(d)
webnotes.conn.sql("""DELETE FROM `tabPrint Format`
WHERE name IN ('Delivery Note Format', 'Purchase Order Format',
'Quotation Format', 'Receivable Voucher Format', 'Sales Order',
'SalesInvoiceModern_test', 'SalesInvoiceStdNew',
'Service Order Format', 'Service Quotation Format')""")
# reload custom print format
for d in webnotes.conn.sql("""select name, module from `tabPrint Format`
where ifnull(standard, 'No') = 'Yes'"""):
try:
reload_doc(d[1], 'Print Format', d[0])
except Exception, e:
print "did not reload: " + str(d)
# Reload GL Mapper
for d in webnotes.conn.sql("select name from `tabGL Mapper`"):
reload_doc('accounts', 'GL Mapper', d[0])
#gl entry, stock ledger entry,
# T0-do-list
# gl mapper name
def delete_search_criteria():
webnotes.conn.sql("""DELETE FROM `tabSearch Criteria`
WHERE name IN ('', 'bills-to_be_paid',
'bills-to_be_submitted', 'cenvat_credit_-_input_or_capital_goods',
@ -84,74 +125,18 @@ def execute():
'projectwise_pending_qty_and_costs_as_per_purchase_cost', 'custom_test', 'custom_test1',
'delivery_notes', 'delivery_note_disabled', 'lead', 'lead_interested', 'lead_report',
'periodic_sales_summary', 'monthly_despatched_trend', 'sales', 'sales_order',
'sales_order1', 'sales_agentwise_commission', 'test_report', 'territory_wise_sales_-_target_vs_actual_')""")
'sales_order1', 'sales_agentwise_commission', 'test_report',
'territory_wise_sales_-_target_vs_actual_')""")
webnotes.conn.sql("""
DELETE FROM `tabSearch Criteria`
WHERE name IN ('monthly_transaction_summary', 'trend_analyzer',
'yearly_transaction_summary', 'invoices-overdue', 'lead-to_follow_up',
'opportunity-to_follow_up', 'serial_no-amc_expiring_this_month',
'serial_no-warranty_expiring_this_month', )
'serial_no-warranty_expiring_this_month')
AND IFNULL(standard, 'No') = 'Yes'
""")
# reload custom search criteria
for d in webnotes.conn.sql("""select name, module from
`tabSearch Criteria` where ifnull(standard, 'No') = 'Yes' and ifnull(disabled, 0) = 0"""):
try:
reload_doc(d[1], 'search_criteria', d[0].replace('-', '_'))
print d
except Exception, e:
print "did not reload: " + str(d)
webnotes.conn.sql("""DELETE FROM `tabPrint Format`
WHERE name IN ('Delivery Note Format', 'Purchase Order Format',
'Quotation Format', 'Receivable Voucher Format', 'Sales Order',
'SalesInvoiceModern_test', 'SalesInvoiceStdNew',
'Service Order Format', 'Service Quotation Format')""")
# reload custom print format
for d in webnotes.conn.sql("""select name, module from `tabPrint Format`
where ifnull(standard, 'No') = 'Yes'"""):
try:
reload_doc(d[1], 'Print Format', d[0])
except Exception, e:
print "did not reload: " + str(d)
# Reload GL Mapper
for d in webnotes.conn.sql("select name from `tabGL Mapper`"):
reload_doc('accounts', 'GL Mapper', d[0])
#gl entry, stock ledger entry,
# T0-do-list
# gl mapper name
def delete_dt_and_mapper():
del_mapper = ['Production Forecast-Production Planning Tool', 'Production Forecast-Production Plan', 'Sales Order-Production Plan']
for d in del_mapper:
delete_doc('DocType Mapper', d)
del_dt = ['Widget Control', 'Update Delivery Date Detail', 'Update Delivery Date',
'Tag Detail', 'Supplier rating', 'Stylesheet', 'Question Tag',
'PRO PP Detail', 'PRO Detail', 'PPW Detail', 'PF Detail',
'Personalize', 'Patch Util', 'Page Template', 'Module Def Role',
'Module Def Item', 'File Group', 'File Browser Control', 'File',
'Educational Qualifications', 'Earn Deduction Detail',
'DocType Property Setter', 'Contact Detail', 'BOM Report Detail',
'BOM Replace Utility Detail', 'BOM Replace Utility',
'Absent Days Detail', 'Activity Dashboard Control', 'Raw Materials Supplied',
'Setup Wizard Control', 'Company Group', 'Lease Agreement', 'Lease Installment'] # docformat
for d in del_dt:
delete_doc('DocType', d)
def rename_in_db(ren_data, data_type, is_doctype):
for d in ren_data:
print colored('Renaming... ' + d + ' --> '+ ren_data[d], 'yellow')
@ -166,7 +151,7 @@ def rename_in_db(ren_data, data_type, is_doctype):
def update_dt_in_records(rendt):
for d in rendt:
# Feed, property setter, search criteria, gl mapper, form 16A, naming series options, doclayer - dodtype is not mentioed in options
dt_list = webnotes.conn.sql("select t1.parent, t1.fieldname from tabDocField t1, tabDocType t2 where t1.parent = t2.name and t1.fieldname in ('dt', 'doctype', 'doc_type', 'dt_type') and ifnull(t1.options, '') = '' and ifnull(t2.issingle, 0) = 0")
dt_list = webnotes.conn.sql("select t1.parent, t1.fieldname from tabDocField t1, tabDocType t2 where t1.parent = t2.name and t1.fieldname in ('dt', 'doctype', 'doc_type', 'dt_type') and ifnull(t1.options, '') = '' and ifnull(t2.issingle, 0) = 0 and t1.parent in ('Custom Field', 'Custom Script')")
for dt in dt_list:
webnotes.conn.sql("update `tab%s` set %s = replace(%s, '%s', '%s') where %s = '%s'" % (dt[0], dt[1], dt[1], d, rendt[d], dt[1], d))

View File

@ -1,15 +1,49 @@
def execute():
import webnotes
sql = webnotes.conn.sql
from webnotes.model import delete_doc
import webnotes
sql = webnotes.conn.sql
from webnotes.model import delete_doc
def execute():
del_rec = {
'DocType' : ['Update Series', 'File', 'File Browser Control', 'File Group', 'Tag Detail', 'DocType Property Setter', 'Company Group'],
'Page' : ['File Browser']
'DocType' : ['Update Series', 'File', 'File Browser Control', 'File Group',
'Tag Detail', 'DocType Property Setter', 'Company Group', 'Widget Control',
'Update Delivery Date Detail', 'Update Delivery Date',
'Tag Detail', 'Supplier rating', 'Stylesheet', 'Question Tag',
'PRO PP Detail', 'PRO Detail', 'PPW Detail', 'PF Detail',
'Personalize', 'Patch Util', 'Page Template', 'Module Def Role',
'Module Def Item', 'File Group', 'File Browser Control', 'File',
'Educational Qualifications', 'Earn Deduction Detail',
'DocType Property Setter', 'Contact Detail', 'BOM Report Detail',
'BOM Replace Utility Detail', 'BOM Replace Utility',
'Absent Days Detail', 'Activity Dashboard Control', 'Raw Materials Supplied',
'Setup Wizard Control', 'Company Group', 'Lease Agreement', 'Lease Installment',
'Terms and Conditions', 'Time Sheet', 'Time Sheet Detail', 'Naming Series Options'],
'Page' : ['File Browser'],
'DocType Mapper': ['Production Forecast-Production Planning Tool', 'Production Forecast-Production Plan', 'Sales Order-Production Plan']
}
for d in del_rec:
for r in del_rec[d]:
if d=='DocType':
sql("delete from tabFeed where doc_type=%s", r)
delete_doc(d, r)
sql("delete from tabDocField where label='Repair Purchase Request' and parent = 'Purchase Request'")
drop_tables()
def drop_tables():
webnotes.conn.commit()
from webnotes.model.db_schema import remove_all_foreign_keys
remove_all_foreign_keys()
count = 0
tab_list = sql("SHOW TABLES")
for tab in tab_list:
if tab[0].startswith('_') or tab[0] in ('tabSingles', 'tabSessions', 'tabSeries'): continue
res = sql("SELECT COUNT(*) FROM `tabDocType` WHERE name = %s", tab[0][3:])
if not res[0][0]:
count += 1
print tab[0]
sql("DROP TABLE `%s`" % tab[0])
print count
webnotes.conn.begin()

View File

@ -22,7 +22,7 @@ cur_frm.cscript.sales_team_fname = "sales_team";
// =====================================================================================
wn.require('erpnext/selling/doctype/sales_common/sales_common.js');
wn.require('erpnext/setup/doctype/other_charges/other_charges.js');
wn.require('erpnext/accounts/doctype/sales_taxes_and_charges_master/sales_taxes_and_charges_master.js');
wn.require('erpnext/utilities/doctype/sms_control/sms_control.js');
wn.require('erpnext/setup/doctype/notification_control/notification_control.js');

View File

@ -18,7 +18,7 @@
// ------
// cur_frm.cscript.tname - Details table name
// cur_frm.cscript.fname - Details fieldname
// cur_frm.cscript.other_fname - wn.require('erpnext/setup/doctype/other_charges/other_charges.js'); fieldname
// cur_frm.cscript.other_fname - wn.require('erpnext/accounts/doctype/sales_taxes_and_charges_master/sales_taxes_and_charges_master.js'); fieldname
// cur_frm.cscript.sales_team_fname - Sales Team fieldname
// ============== Load Default Taxes ===================

View File

@ -23,7 +23,7 @@ cur_frm.cscript.sales_team_fname = "sales_team";
wn.require('erpnext/selling/doctype/sales_common/sales_common.js');
wn.require('erpnext/setup/doctype/other_charges/other_charges.js');
wn.require('erpnext/accounts/doctype/sales_taxes_and_charges_master/sales_taxes_and_charges_master.js');
wn.require('erpnext/utilities/doctype/sms_control/sms_control.js');
wn.require('erpnext/setup/doctype/notification_control/notification_control.js');

View File

@ -114,8 +114,7 @@ var update_messages = function(reset) {
if(inList(['Guest'], user) || !wn.session_alive) { return; }
if(!reset) {
$c_page('home', 'event_updates', 'get_global_status_messages', null,
function(r,rt) {
var set_messages = function(r) {
if(!r.exc) {
// This function is defined in toolbar.js
wn.container.wntoolbar.set_new_comments(r.message.unread_messages);
@ -141,7 +140,12 @@ var update_messages = function(reset) {
clearInterval(wn.updates.id);
}
}
);
wn.call({
method: 'startup.startup.get_global_status_messages',
callback: set_messages
});
} else {
wn.container.wntoolbar.set_new_comments(0);
$('#unread_messages').toggle(false);

View File

@ -0,0 +1,54 @@
import webnotes
def get_unread_messages():
"returns unread (docstatus-0 messages for a user)"
return webnotes.conn.sql("""\
SELECT name, comment
FROM `tabComment`
WHERE comment_doctype IN ('My Company', 'Message')
AND comment_docname = %s
AND ifnull(docstatus,0)=0
""", webnotes.user.name, as_list=1)
def get_open_support_tickets():
"""
Returns a count of open support tickets
"""
from webnotes.utils import cint
open_support_tickets = webnotes.conn.sql("""\
SELECT COUNT(*) FROM `tabSupport Ticket`
WHERE status = 'Open'""")
return open_support_tickets and cint(open_support_tickets[0][0]) or 0
def get_things_todo():
"""
Returns a count of incomplete todos
"""
from webnotes.utils import cint
incomplete_todos = webnotes.conn.sql("""\
SELECT COUNT(*) FROM `tabToDo`
WHERE IFNULL(checked, 0) = 0
AND owner = %s""", webnotes.session.get('user'))
return incomplete_todos and cint(incomplete_todos[0][0]) or 0
def get_todays_events():
"""
Returns a count of todays events in calendar
"""
from webnotes.utils import nowdate, cint
todays_events = webnotes.conn.sql("""\
SELECT COUNT(*) FROM `tabEvent`
WHERE owner = %s
AND event_type != 'Cancel'
AND event_date = %s""", (
webnotes.session.get('user'), nowdate()))
return todays_events and cint(todays_events[0][0]) or 0
@webnotes.whitelist()
def get_global_status_messages(arg=None):
return {
'unread_messages': get_unread_messages(),
'open_support_tickets': get_open_support_tickets(),
'things_todo': get_things_todo(),
'todays_events': get_todays_events(),
}

View File

@ -21,7 +21,7 @@ cur_frm.cscript.other_fname = "other_charges";
cur_frm.cscript.sales_team_fname = "sales_team";
wn.require('erpnext/selling/doctype/sales_common/sales_common.js');
wn.require('erpnext/setup/doctype/other_charges/other_charges.js');
wn.require('erpnext/accounts/doctype/sales_taxes_and_charges_master/sales_taxes_and_charges_master.js');
wn.require('erpnext/utilities/doctype/sms_control/sms_control.js');
wn.require('erpnext/setup/doctype/notification_control/notification_control.js');

View File

@ -18,7 +18,7 @@ cur_frm.cscript.tname = "Purchase Receipt Item";
cur_frm.cscript.fname = "purchase_receipt_details";
cur_frm.cscript.other_fname = "purchase_tax_details";
wn.require('erpnext/buying/doctype/purchase_other_charges/purchase_other_charges.js');
wn.require('erpnext/accounts/doctype/purchase_taxes_and_charges_master/purchase_taxes_and_charges_master.js');
wn.require('erpnext/buying/doctype/purchase_common/purchase_common.js');
wn.require('erpnext/utilities/doctype/sms_control/sms_control.js');
wn.require('erpnext/setup/doctype/notification_control/notification_control.js');

View File

@ -69,8 +69,40 @@ def post(arg=None):
d.comment_doctype = 'Message'
d.save()
import webnotes.utils
if webnotes.utils.cint(arg.get('notify')):
notify(arg)
@webnotes.whitelist()
def delete(arg=None):
webnotes.conn.sql("""delete from `tabComment` where name=%s""",
webnotes.form_dict['name']);
def notify(arg=None):
from webnotes.utils import cstr
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
message = '''A new comment has been posted on your page by %s:
<b>Comment:</b> %s
To answer, please login to your erpnext account!
<a href='https://signin.erpnext.com'>https://signin.erpnext.com</a>
''' % (fn, arg['txt'])
from webnotes.model.code import get_obj
note = get_obj('Notification Control')
email_msg = note.prepare_message({
'type': 'New Comment',
'message': message
})
sender = webnotes.user.name!='Administrator' and webnotes.user.name or 'support+admin_post@erpnext.com'
from webnotes.utils.email_lib import sendmail
sendmail([arg['contact']], sender, email_msg, fn + ' has posted a new comment')

View File

@ -2228,8 +2228,9 @@ else if(nm=='Accounts Browser')
pscript.make_chart(chart_type);}
loadpage(nm,call_back);}
var update_messages=function(reset){if(inList(['Guest'],user)||!wn.session_alive){return;}
if(!reset){$c_page('home','event_updates','get_global_status_messages',null,function(r,rt){if(!r.exc){wn.container.wntoolbar.set_new_comments(r.message.unread_messages);var show_in_circle=function(parent_id,msg){var parent=$('#'+parent_id);if(parent){if(msg){parent.find('span:first').text(msg);parent.toggle(true);}else{parent.toggle(false);}}}
show_in_circle('unread_messages',r.message.unread_messages.length);show_in_circle('open_support_tickets',r.message.open_support_tickets);show_in_circle('things_todo',r.message.things_todo);show_in_circle('todays_events',r.message.todays_events);}else{clearInterval(wn.updates.id);}});}else{wn.container.wntoolbar.set_new_comments(0);$('#unread_messages').toggle(false);}}
if(!reset){var set_messages=function(r){if(!r.exc){wn.container.wntoolbar.set_new_comments(r.message.unread_messages);var show_in_circle=function(parent_id,msg){var parent=$('#'+parent_id);if(parent){if(msg){parent.find('span:first').text(msg);parent.toggle(true);}else{parent.toggle(false);}}}
show_in_circle('unread_messages',r.message.unread_messages.length);show_in_circle('open_support_tickets',r.message.open_support_tickets);show_in_circle('things_todo',r.message.things_todo);show_in_circle('todays_events',r.message.todays_events);}else{clearInterval(wn.updates.id);}}
wn.call({method:'startup.startup.get_global_status_messages',callback:set_messages});}else{wn.container.wntoolbar.set_new_comments(0);$('#unread_messages').toggle(false);}}
erpnext.startup.set_periodic_updates=function(){wn.updates={};if(wn.updates.id){clearInterval(wn.updates.id);}
wn.updates.id=setInterval(update_messages,60000);}
erpnext.set_user_background=function(src){set_style(repl('body { background: url("files/%(src)s") repeat;}',{src:src}))}

View File

@ -1256,8 +1256,9 @@ else if(nm=='Accounts Browser')
pscript.make_chart(chart_type);}
loadpage(nm,call_back);}
var update_messages=function(reset){if(inList(['Guest'],user)||!wn.session_alive){return;}
if(!reset){$c_page('home','event_updates','get_global_status_messages',null,function(r,rt){if(!r.exc){wn.container.wntoolbar.set_new_comments(r.message.unread_messages);var show_in_circle=function(parent_id,msg){var parent=$('#'+parent_id);if(parent){if(msg){parent.find('span:first').text(msg);parent.toggle(true);}else{parent.toggle(false);}}}
show_in_circle('unread_messages',r.message.unread_messages.length);show_in_circle('open_support_tickets',r.message.open_support_tickets);show_in_circle('things_todo',r.message.things_todo);show_in_circle('todays_events',r.message.todays_events);}else{clearInterval(wn.updates.id);}});}else{wn.container.wntoolbar.set_new_comments(0);$('#unread_messages').toggle(false);}}
if(!reset){var set_messages=function(r){if(!r.exc){wn.container.wntoolbar.set_new_comments(r.message.unread_messages);var show_in_circle=function(parent_id,msg){var parent=$('#'+parent_id);if(parent){if(msg){parent.find('span:first').text(msg);parent.toggle(true);}else{parent.toggle(false);}}}
show_in_circle('unread_messages',r.message.unread_messages.length);show_in_circle('open_support_tickets',r.message.open_support_tickets);show_in_circle('things_todo',r.message.things_todo);show_in_circle('todays_events',r.message.todays_events);}else{clearInterval(wn.updates.id);}}
wn.call({method:'startup.startup.get_global_status_messages',callback:set_messages});}else{wn.container.wntoolbar.set_new_comments(0);$('#unread_messages').toggle(false);}}
erpnext.startup.set_periodic_updates=function(){wn.updates={};if(wn.updates.id){clearInterval(wn.updates.id);}
wn.updates.id=setInterval(update_messages,60000);}
erpnext.set_user_background=function(src){set_style(repl('body { background: url("files/%(src)s") repeat;}',{src:src}))}

View File

@ -1 +1 @@
1492
1495

4
wnf.py
View File

@ -242,11 +242,11 @@ def run():
elif options.sync_all is not None:
import webnotes.model.sync
webnotes.model.sync.sync_all()
webnotes.model.sync.sync_all(options.force or 0)
elif options.sync is not None:
import webnotes.model.sync
webnotes.model.sync.sync(options.sync[0], options.sync[1])
webnotes.model.sync.sync(options.sync[0], options.sync[1], options.force or 0)
# print messages
if webnotes.message_log: