Merge branch '1209' of github.com:webnotes/erpnext into 1209
This commit is contained in:
commit
b83307823b
@ -69,12 +69,12 @@
|
|||||||
href="#!Form/Sales and Purchase Return Tool/Sales and Purchase Return Tool">Sales or Purchase Returns</a>
|
href="#!Form/Sales and Purchase Return Tool/Sales and Purchase Return Tool">Sales or Purchase Returns</a>
|
||||||
</div>
|
</div>
|
||||||
<div class="section-item">
|
<div class="section-item">
|
||||||
<a class="section-link"
|
<a class="section-link" data-role="Analytics"
|
||||||
title = "Analyze Sales and Purchase trends and slice them based on item, customer, groups etc"
|
title = "Analyze Sales and Purchase trends and slice them based on item, customer, groups etc"
|
||||||
href="#!Report/Profile/Trend Analyzer">Trend Analyzer</a>
|
href="#!Report/Profile/Trend Analyzer">Trend Analyzer</a>
|
||||||
</div>
|
</div>
|
||||||
<div class="section-item">
|
<div class="section-item">
|
||||||
<a class="section-link"
|
<a class="section-link" data-role="Accounts Manager"
|
||||||
title = "Check your Balance Sheet and Profit & Loss Statement"
|
title = "Check your Balance Sheet and Profit & Loss Statement"
|
||||||
href="#!Financial Statements">Financial Statements</a>
|
href="#!Financial Statements">Financial Statements</a>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -3,9 +3,9 @@
|
|||||||
|
|
||||||
# These values are common in all dictionaries
|
# These values are common in all dictionaries
|
||||||
{
|
{
|
||||||
u'creation': '2012-07-18 20:34:41',
|
u'creation': '2012-09-21 09:56:34',
|
||||||
u'docstatus': 0,
|
u'docstatus': 0,
|
||||||
u'modified': '2012-09-17 11:31:55',
|
u'modified': '2012-09-28 12:31:42',
|
||||||
u'modified_by': u'Administrator',
|
u'modified_by': u'Administrator',
|
||||||
u'owner': u'Administrator'
|
u'owner': u'Administrator'
|
||||||
},
|
},
|
||||||
@ -454,23 +454,13 @@
|
|||||||
# DocPerm
|
# DocPerm
|
||||||
{
|
{
|
||||||
'amend': 0,
|
'amend': 0,
|
||||||
'cancel': 1,
|
'cancel': 0,
|
||||||
'create': 1,
|
'create': 0,
|
||||||
u'doctype': u'DocPerm',
|
u'doctype': u'DocPerm',
|
||||||
'permlevel': 0,
|
'permlevel': 1,
|
||||||
'role': u'Sales Master Manager',
|
'role': u'Sales Manager',
|
||||||
'submit': 0,
|
'submit': 0,
|
||||||
'write': 1
|
'write': 0
|
||||||
},
|
|
||||||
|
|
||||||
# DocPerm
|
|
||||||
{
|
|
||||||
'cancel': 1,
|
|
||||||
'create': 1,
|
|
||||||
u'doctype': u'DocPerm',
|
|
||||||
'permlevel': 0,
|
|
||||||
'role': u'Accounts Manager',
|
|
||||||
'write': 1
|
|
||||||
},
|
},
|
||||||
|
|
||||||
# DocPerm
|
# DocPerm
|
||||||
@ -491,7 +481,7 @@
|
|||||||
'cancel': 0,
|
'cancel': 0,
|
||||||
'create': 0,
|
'create': 0,
|
||||||
u'doctype': u'DocPerm',
|
u'doctype': u'DocPerm',
|
||||||
'permlevel': 0,
|
'permlevel': 1,
|
||||||
'role': u'Sales User',
|
'role': u'Sales User',
|
||||||
'submit': 0,
|
'submit': 0,
|
||||||
'write': 0
|
'write': 0
|
||||||
@ -503,14 +493,40 @@
|
|||||||
'cancel': 0,
|
'cancel': 0,
|
||||||
'create': 0,
|
'create': 0,
|
||||||
u'doctype': u'DocPerm',
|
u'doctype': u'DocPerm',
|
||||||
'permlevel': 1,
|
'permlevel': 0,
|
||||||
'role': u'All',
|
'role': u'Sales User',
|
||||||
'submit': 0,
|
'submit': 0,
|
||||||
'write': 0
|
'write': 0
|
||||||
},
|
},
|
||||||
|
|
||||||
# DocPerm
|
# DocPerm
|
||||||
{
|
{
|
||||||
|
'amend': 0,
|
||||||
|
'cancel': 1,
|
||||||
|
'create': 1,
|
||||||
|
u'doctype': u'DocPerm',
|
||||||
|
'permlevel': 0,
|
||||||
|
'role': u'Sales Master Manager',
|
||||||
|
'submit': 0,
|
||||||
|
'write': 1
|
||||||
|
},
|
||||||
|
|
||||||
|
# DocPerm
|
||||||
|
{
|
||||||
|
'amend': 0,
|
||||||
|
'cancel': 0,
|
||||||
|
'create': 0,
|
||||||
|
u'doctype': u'DocPerm',
|
||||||
|
'permlevel': 1,
|
||||||
|
'role': u'Sales Master Manager',
|
||||||
|
'submit': 0,
|
||||||
|
'write': 0
|
||||||
|
},
|
||||||
|
|
||||||
|
# DocPerm
|
||||||
|
{
|
||||||
|
'cancel': 0,
|
||||||
|
'create': 0,
|
||||||
u'doctype': u'DocPerm',
|
u'doctype': u'DocPerm',
|
||||||
'permlevel': 2,
|
'permlevel': 2,
|
||||||
'role': u'Accounts Manager',
|
'role': u'Accounts Manager',
|
||||||
@ -519,6 +535,8 @@
|
|||||||
|
|
||||||
# DocPerm
|
# DocPerm
|
||||||
{
|
{
|
||||||
|
'cancel': 0,
|
||||||
|
'create': 0,
|
||||||
u'doctype': u'DocPerm',
|
u'doctype': u'DocPerm',
|
||||||
'permlevel': 2,
|
'permlevel': 2,
|
||||||
'role': u'System Manager',
|
'role': u'System Manager',
|
||||||
@ -527,8 +545,31 @@
|
|||||||
|
|
||||||
# DocPerm
|
# DocPerm
|
||||||
{
|
{
|
||||||
|
'cancel': 0,
|
||||||
|
'create': 0,
|
||||||
u'doctype': u'DocPerm',
|
u'doctype': u'DocPerm',
|
||||||
'permlevel': 2,
|
'permlevel': 2,
|
||||||
'role': u'All'
|
'role': u'All',
|
||||||
|
'write': 0
|
||||||
|
},
|
||||||
|
|
||||||
|
# DocPerm
|
||||||
|
{
|
||||||
|
'cancel': 1,
|
||||||
|
'create': 1,
|
||||||
|
u'doctype': u'DocPerm',
|
||||||
|
'permlevel': 0,
|
||||||
|
'role': u'Accounts Manager',
|
||||||
|
'write': 1
|
||||||
|
},
|
||||||
|
|
||||||
|
# DocPerm
|
||||||
|
{
|
||||||
|
'cancel': 0,
|
||||||
|
'create': 0,
|
||||||
|
u'doctype': u'DocPerm',
|
||||||
|
'permlevel': 1,
|
||||||
|
'role': u'All',
|
||||||
|
'write': 0
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
@ -45,7 +45,7 @@ cur_frm.cscript.onload = function(doc, cdt, cdn) {
|
|||||||
cur_frm.cscript.make_communication_body();
|
cur_frm.cscript.make_communication_body();
|
||||||
}
|
}
|
||||||
|
|
||||||
cur_frm.cscript.refresh_custom_buttons = function() {
|
cur_frm.cscript.refresh_custom_buttons = function(doc) {
|
||||||
cur_frm.clear_custom_buttons();
|
cur_frm.clear_custom_buttons();
|
||||||
if(!doc.__islocal && !in_list(['Converted', 'Lead Lost'], doc.status)) {
|
if(!doc.__islocal && !in_list(['Converted', 'Lead Lost'], doc.status)) {
|
||||||
if (doc.source != 'Existing Customer') {
|
if (doc.source != 'Existing Customer') {
|
||||||
@ -61,7 +61,7 @@ cur_frm.cscript.refresh_custom_buttons = function() {
|
|||||||
cur_frm.cscript.refresh = function(doc, cdt, cdn) {
|
cur_frm.cscript.refresh = function(doc, cdt, cdn) {
|
||||||
// custom buttons
|
// custom buttons
|
||||||
//---------------
|
//---------------
|
||||||
cur_frm.cscript.refresh_custom_buttons();
|
cur_frm.cscript.refresh_custom_buttons(doc);
|
||||||
|
|
||||||
erpnext.hide_naming_series();
|
erpnext.hide_naming_series();
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
select
|
SELECT
|
||||||
`tabCustomer`.name,
|
`tabCustomer`.name,
|
||||||
`tabCustomer`.customer_name,
|
`tabCustomer`.customer_name,
|
||||||
`tabAddress`.address_line1,
|
`tabAddress`.address_line1,
|
||||||
@ -12,7 +12,7 @@ select
|
|||||||
`tabContact`.phone,
|
`tabContact`.phone,
|
||||||
`tabContact`.mobile_no,
|
`tabContact`.mobile_no,
|
||||||
`tabContact`.email_id
|
`tabContact`.email_id
|
||||||
from
|
FROM
|
||||||
`tabCustomer`
|
`tabCustomer`
|
||||||
left join `tabAddress` on (
|
left join `tabAddress` on (
|
||||||
`tabAddress`.customer=`tabCustomer`.name and
|
`tabAddress`.customer=`tabCustomer`.name and
|
||||||
@ -22,5 +22,7 @@ from
|
|||||||
`tabContact`.customer=`tabCustomer`.name and
|
`tabContact`.customer=`tabCustomer`.name and
|
||||||
ifnull(`tabContact`.is_primary_contact, 0)=1
|
ifnull(`tabContact`.is_primary_contact, 0)=1
|
||||||
)
|
)
|
||||||
order by
|
WHERE
|
||||||
|
`tabCustomer`.docstatus<2
|
||||||
|
ORDER BY
|
||||||
`tabCustomer`.customer_name asc
|
`tabCustomer`.customer_name asc
|
||||||
@ -16,7 +16,19 @@
|
|||||||
|
|
||||||
// Validate
|
// Validate
|
||||||
cur_frm.cscript.validate = function(doc, cdt, cdn) {
|
cur_frm.cscript.validate = function(doc, cdt, cdn) {
|
||||||
$c_obj(make_doclist(cdt, cdn), 'get_defaults', '', function(r, rt){
|
$c_obj(make_doclist(cdt, cdn), 'get_defaults', '', function(r, rt){
|
||||||
sys_defaults = r.message;
|
sys_defaults = r.message;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cur_frm.fields_dict['default_territory'].get_query = function(doc,cdt,cdn) {
|
||||||
|
return 'SELECT `tabTerritory`.`name`,`tabTerritory`.`parent_territory` FROM `tabTerritory` WHERE `tabTerritory`.`is_group` = "No" AND `tabTerritory`.`docstatus`!= 2 AND `tabTerritory`.%(key)s LIKE "%s" ORDER BY `tabTerritory`.`name` ASC LIMIT 50';
|
||||||
|
}
|
||||||
|
|
||||||
|
cur_frm.fields_dict['default_customer_group'].get_query = function(doc,cdt,cdn) {
|
||||||
|
return 'SELECT `tabCustomer Group`.`name`, `tabCustomer Group`.`parent_customer_group` FROM `tabCustomer Group` WHERE `tabCustomer Group`.`is_group` = "No" AND `tabCustomer Group`.`docstatus`!= 2 AND `tabCustomer Group`.%(key)s LIKE "%s" ORDER BY `tabCustomer Group`.`name` ASC LIMIT 50';
|
||||||
|
}
|
||||||
|
|
||||||
|
cur_frm.fields_dict['default_item_group'].get_query = function(doc,cdt,cdn) {
|
||||||
|
return 'SELECT `tabItem Group`.`name`,`tabItem Group`.`parent_item_group` FROM `tabItem Group` WHERE `tabItem Group`.is_group="No" AND `tabItem Group`.docstatus != 2 AND `tabItem Group`.%(key)s LIKE "%s" LIMIT 50'
|
||||||
|
}
|
||||||
|
|||||||
@ -28,13 +28,19 @@ erpnext.module_page.setup_page = function(module, wrapper) {
|
|||||||
// not have read permissions
|
// not have read permissions
|
||||||
|
|
||||||
erpnext.module_page.hide_links = function(wrapper) {
|
erpnext.module_page.hide_links = function(wrapper) {
|
||||||
|
function replace_link(link) {
|
||||||
|
var txt = $(link).text();
|
||||||
|
$(link).parent().css('color', '#999');
|
||||||
|
$(link).replaceWith('<span title="No read permission">'
|
||||||
|
+txt+'</span>');
|
||||||
|
}
|
||||||
|
|
||||||
// lists
|
// lists
|
||||||
$(wrapper).find('[href*="List/"]').each(function() {
|
$(wrapper).find('[href*="List/"]').each(function() {
|
||||||
var href = $(this).attr('href');
|
var href = $(this).attr('href');
|
||||||
var dt = href.split('/')[1];
|
var dt = href.split('/')[1];
|
||||||
if(wn.boot.profile.all_read.indexOf(get_label_doctype(dt))==-1) {
|
if(wn.boot.profile.all_read.indexOf(get_label_doctype(dt))==-1) {
|
||||||
var txt = $(this).text();
|
replace_link(this);
|
||||||
$(this).parent().css('color', '#999').html(txt);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -42,8 +48,7 @@ erpnext.module_page.hide_links = function(wrapper) {
|
|||||||
$(wrapper).find('[data-doctype]').each(function() {
|
$(wrapper).find('[data-doctype]').each(function() {
|
||||||
var dt = $(this).attr('data-doctype');
|
var dt = $(this).attr('data-doctype');
|
||||||
if(wn.boot.profile.all_read.indexOf(dt)==-1) {
|
if(wn.boot.profile.all_read.indexOf(dt)==-1) {
|
||||||
var txt = $(this).text();
|
replace_link(this);
|
||||||
$(this).parent().css('color', '#999').html(txt);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -52,8 +57,7 @@ erpnext.module_page.hide_links = function(wrapper) {
|
|||||||
var href = $(this).attr('href');
|
var href = $(this).attr('href');
|
||||||
var dt = href.split('/')[1];
|
var dt = href.split('/')[1];
|
||||||
if(wn.boot.profile.all_read.indexOf(get_label_doctype(dt))==-1) {
|
if(wn.boot.profile.all_read.indexOf(get_label_doctype(dt))==-1) {
|
||||||
var txt = $(this).text();
|
replace_link(this);
|
||||||
$(this).parent().css('color', '#999').html(txt);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -62,7 +66,9 @@ erpnext.module_page.hide_links = function(wrapper) {
|
|||||||
if(!has_common(user_roles, [$(this).attr("data-role"), "System Manager"])) {
|
if(!has_common(user_roles, [$(this).attr("data-role"), "System Manager"])) {
|
||||||
var html = $(this).html();
|
var html = $(this).html();
|
||||||
$(this).parent().css('color', '#999');
|
$(this).parent().css('color', '#999');
|
||||||
$(this).replaceWith(html);
|
$(this).replaceWith('<span title="Only accessible by Roles: '+
|
||||||
|
$(this).attr("data-role")
|
||||||
|
+' and System Manager">'+html+'</span>');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@ -195,3 +195,14 @@ erpnext.hide_naming_series = function() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Mousetrap.bind(["command+g", "ctrl+g"], function() {
|
||||||
|
wn.ui.toolbar.search.show();
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
|
||||||
|
Mousetrap.bind(["command+s", "ctrl+s"], function() {
|
||||||
|
if(cur_frm)
|
||||||
|
cur_frm.save();
|
||||||
|
return false;
|
||||||
|
});
|
||||||
@ -1,17 +1,12 @@
|
|||||||
#message-post-text {
|
#message-post-text {
|
||||||
width: 50%;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#message-list {
|
#message-list {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.message {
|
.message {
|
||||||
border-radius: 5px;
|
|
||||||
max-width: 60%;
|
|
||||||
min-width: 40%;
|
|
||||||
padding: 7px;
|
padding: 7px;
|
||||||
margin-bottom: 7px;
|
border-bottom: 1px solid #ccc;
|
||||||
}
|
}
|
||||||
|
|
||||||
.message .help {
|
.message .help {
|
||||||
@ -22,14 +17,8 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.message-other {
|
.message-other {
|
||||||
background-color: #EBFF9C;
|
|
||||||
border: 1px solid #C3CF78;
|
|
||||||
float: right;
|
|
||||||
text-align: right;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.message-self {
|
.message-self {
|
||||||
background-color: #eee;
|
background-color: #eee;
|
||||||
border: 1px solid #ccc;
|
|
||||||
float: left;
|
|
||||||
}
|
}
|
||||||
@ -1,28 +0,0 @@
|
|||||||
<div class="layout-wrapper layout-wrapper-background">
|
|
||||||
<div class="layout-main-section">
|
|
||||||
<a class="close" onclick="window.history.back();">×</a>
|
|
||||||
<h1>Messages</h1>
|
|
||||||
<div class="well">
|
|
||||||
<input id="message-post-text"></input>
|
|
||||||
<button disabled="disabled" id="message-post" class="btn btn-small"><i class="icon-play"></i> Post</button>
|
|
||||||
</div>
|
|
||||||
<div id="message-list">
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="layout-side-section">
|
|
||||||
<div class="psidebar">
|
|
||||||
<div class="section">
|
|
||||||
<div class="section-head">
|
|
||||||
Messages By
|
|
||||||
</div>
|
|
||||||
<div class="section-body">
|
|
||||||
<div class="section-item">
|
|
||||||
<a href="#!messages"><b>All messages</b></a>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div style="clear: both;">
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
@ -17,71 +17,87 @@
|
|||||||
wn.provide('erpnext.messages');
|
wn.provide('erpnext.messages');
|
||||||
|
|
||||||
wn.pages.messages.onload = function(wrapper) {
|
wn.pages.messages.onload = function(wrapper) {
|
||||||
erpnext.messages.show_active_users();
|
wn.ui.make_app_page({
|
||||||
erpnext.messages.make_list();
|
parent: wrapper,
|
||||||
erpnext.update_messages('reset'); //Resets notification icons
|
title: "Messages"
|
||||||
|
|
||||||
// post message
|
|
||||||
$('#message-post').click(function() {
|
|
||||||
var txt = $('#message-post-text').val();
|
|
||||||
if(txt) {
|
|
||||||
wn.call({
|
|
||||||
module:'utilities',
|
|
||||||
page:'messages',
|
|
||||||
method:'post',
|
|
||||||
args: {
|
|
||||||
txt: txt,
|
|
||||||
contact: erpnext.messages.contact
|
|
||||||
},
|
|
||||||
callback:function(r,rt) {
|
|
||||||
$('#message-post-text').val('')
|
|
||||||
erpnext.messages.list.run();
|
|
||||||
},
|
|
||||||
btn: this
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// enable, disable button
|
$('<h3 id="message-title">Everyone</h3>\
|
||||||
$('#message-post-text').keyup(function(e) {
|
<div id="show-everyone" style="display: none;">\
|
||||||
if($(this).val()) {
|
<a href="#messages" style="font-size: 80%;">\
|
||||||
$('#message-post').attr('disabled', false);
|
Show messages from everyone</a></div><hr>\
|
||||||
} else {
|
<div id="post-message" style="display: none">\
|
||||||
$('#message-post').attr('disabled', true);
|
<textarea style="width: 100%; height: 24px;"></textarea>\
|
||||||
}
|
<div><button class="btn btn-small">Post</button></div><hr>\
|
||||||
|
</div>\
|
||||||
if(e.which==13) {
|
<div class="all-messages"></div>').appendTo($(wrapper).find('.layout-main-section'));
|
||||||
$('#message-post').click();
|
|
||||||
}
|
erpnext.messages = new erpnext.Messages(wrapper);
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$(wn.pages.messages).bind('show', function() {
|
$(wn.pages.messages).bind('show', function() {
|
||||||
erpnext.messages.show();
|
erpnext.messages.show();
|
||||||
setTimeout(erpnext.messages.refresh, 7000);
|
setTimeout("erpnext.messages.refresh()", 7000);
|
||||||
$('#message-post-text').focus();
|
|
||||||
})
|
})
|
||||||
|
|
||||||
erpnext.messages = {
|
erpnext.Messages = Class.extend({
|
||||||
|
init: function(wrapper) {
|
||||||
|
this.wrapper = wrapper;
|
||||||
|
this.show_active_users();
|
||||||
|
this.make_post_message();
|
||||||
|
this.make_list();
|
||||||
|
//this.update_messages('reset'); //Resets notification icons
|
||||||
|
},
|
||||||
|
make_post_message: function() {
|
||||||
|
var me = this;
|
||||||
|
$('#post-message textarea').keydown(function(e) {
|
||||||
|
if(e.which==13) {
|
||||||
|
$('#post-message .btn').click();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
$('#post-message .btn').click(function() {
|
||||||
|
var txt = $('#post-message textarea').val();
|
||||||
|
if(txt) {
|
||||||
|
wn.call({
|
||||||
|
module:'utilities',
|
||||||
|
page:'messages',
|
||||||
|
method:'post',
|
||||||
|
args: {
|
||||||
|
txt: txt,
|
||||||
|
contact: me.contact
|
||||||
|
},
|
||||||
|
callback:function(r,rt) {
|
||||||
|
$('#post-message textarea').val('')
|
||||||
|
me.list.run();
|
||||||
|
},
|
||||||
|
btn: this
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
show: function() {
|
show: function() {
|
||||||
var contact = erpnext.messages.get_contact();
|
var contact = this.get_contact();
|
||||||
|
|
||||||
|
$('#message-title').text(contact==user ? "Everyone" :
|
||||||
|
wn.boot.user_info[contact].fullname)
|
||||||
|
|
||||||
|
$("#show-everyone").toggle(contact!=user);
|
||||||
|
|
||||||
// can't send message to self
|
// can't send message to self
|
||||||
$(wn.pages.messages).find('.well').toggle(contact==user ? false : true);
|
$('#post-message').toggle(contact!=user);
|
||||||
|
|
||||||
$(wn.pages.messages).find('h1:first').html('Messages: '
|
this.contact = contact;
|
||||||
+ (user==contact ? 'From everyone' : wn.user_info(contact).fullname));
|
this.list.opts.args.contact = contact;
|
||||||
|
this.list.run();
|
||||||
erpnext.messages.contact = contact;
|
|
||||||
erpnext.messages.list.opts.args.contact = contact;
|
|
||||||
erpnext.messages.list.run();
|
|
||||||
|
|
||||||
},
|
},
|
||||||
// check for updates every 5 seconds if page is active
|
// check for updates every 5 seconds if page is active
|
||||||
refresh: function() {
|
refresh: function() {
|
||||||
setTimeout(erpnext.messages.refresh, 7000);
|
setTimeout("erpnext.messages.refresh()", 7000);
|
||||||
if(wn.container.page.label != 'Messages') return;
|
if(wn.container.page.label != 'Messages') return;
|
||||||
erpnext.messages.show();
|
this.show();
|
||||||
},
|
},
|
||||||
get_contact: function() {
|
get_contact: function() {
|
||||||
var route = location.hash;
|
var route = location.hash;
|
||||||
@ -95,12 +111,14 @@ erpnext.messages = {
|
|||||||
return user;
|
return user;
|
||||||
},
|
},
|
||||||
make_list: function() {
|
make_list: function() {
|
||||||
erpnext.messages.list = new wn.ui.Listing({
|
this.list = new wn.ui.Listing({
|
||||||
parent: $('#message-list').get(0),
|
parent: $(this.wrapper).find('.all-messages'),
|
||||||
method: 'utilities.page.messages.messages.get_list',
|
method: 'utilities.page.messages.messages.get_list',
|
||||||
args: {
|
args: {
|
||||||
contact: null
|
contact: null
|
||||||
},
|
},
|
||||||
|
hide_refresh: true,
|
||||||
|
no_loading: true,
|
||||||
render_row: function(wrapper, data) {
|
render_row: function(wrapper, data) {
|
||||||
$(wrapper).removeClass('list-row');
|
$(wrapper).removeClass('list-row');
|
||||||
|
|
||||||
@ -111,18 +129,22 @@ erpnext.messages = {
|
|||||||
if(data.owner==user) {
|
if(data.owner==user) {
|
||||||
data.cls = 'message-self';
|
data.cls = 'message-self';
|
||||||
data.comment_by_fullname = 'You';
|
data.comment_by_fullname = 'You';
|
||||||
data.delete_html = repl('<a class="close" \
|
|
||||||
onclick="erpnext.messages.delete(this)"\
|
|
||||||
data-name="%(name)s">×</a>', data);
|
|
||||||
} else {
|
} else {
|
||||||
data.cls = 'message-other';
|
data.cls = 'message-other';
|
||||||
data.delete_html = '';
|
if(this.contact==user) {
|
||||||
if(erpnext.messages.contact==user) {
|
|
||||||
data.reply_html = repl('<a href="#!messages/%(owner)s">\
|
data.reply_html = repl('<a href="#!messages/%(owner)s">\
|
||||||
<i class="icon-share-alt"></i> Reply</a>', data)
|
<i class="icon-share-alt"></i> Reply</a>', data)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// delete
|
||||||
|
data.delete_html = "";
|
||||||
|
if(data.owner==user || data.comment.indexOf("assigned to")!=-1) {
|
||||||
|
data.delete_html = repl('<a class="close" \
|
||||||
|
onclick="erpnext.messages.delete(this)"\
|
||||||
|
data-name="%(name)s">×</a>', data);
|
||||||
|
}
|
||||||
|
|
||||||
wrapper.innerHTML = repl('<div class="message %(cls)s">%(delete_html)s\
|
wrapper.innerHTML = repl('<div class="message %(cls)s">%(delete_html)s\
|
||||||
<b>%(comment)s</b>\
|
<b>%(comment)s</b>\
|
||||||
<div class="help">by %(comment_by_fullname)s, %(creation)s</div>\
|
<div class="help">by %(comment_by_fullname)s, %(creation)s</div>\
|
||||||
@ -142,22 +164,30 @@ erpnext.messages = {
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
show_active_users: function() {
|
show_active_users: function() {
|
||||||
|
var me = this;
|
||||||
wn.call({
|
wn.call({
|
||||||
module:'utilities',
|
module:'utilities',
|
||||||
page:'messages',
|
page:'messages',
|
||||||
method:'get_active_users',
|
method:'get_active_users',
|
||||||
callback: function(r,rt) {
|
callback: function(r,rt) {
|
||||||
var $body = $(wn.pages.messages).find('.section-body');
|
var $body = $(me.wrapper).find('.layout-side-section');
|
||||||
|
$("<h4>Users</h4><hr>").appendTo($body);
|
||||||
for(var i in r.message) {
|
for(var i in r.message) {
|
||||||
var p = r.message[i];
|
var p = r.message[i];
|
||||||
p.fullname = wn.user_info(p.name).fullname;
|
if(p.name != user) {
|
||||||
p.name = p.name.replace('@', '__at__');
|
p.fullname = wn.user_info(p.name).fullname;
|
||||||
$body.append(repl('<div class="section-item">\
|
p.name = p.name.replace('@', '__at__');
|
||||||
<a href="#!messages/%(name)s">%(fullname)s</a></div>', p))
|
p.label_status = p.has_session ? "label-success" : "";
|
||||||
|
p.status = p.has_session ? "Online" : "Offline";
|
||||||
|
$(repl('<p><span class="label %(label_status)s">%(status)s</span>\
|
||||||
|
<a href="#!messages/%(name)s">%(fullname)s</a>\
|
||||||
|
</p>', p))
|
||||||
|
.appendTo($body);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -48,7 +48,10 @@ def get_list(arg=None):
|
|||||||
|
|
||||||
@webnotes.whitelist()
|
@webnotes.whitelist()
|
||||||
def get_active_users(arg=None):
|
def get_active_users(arg=None):
|
||||||
return webnotes.conn.sql("""select name from tabProfile
|
return webnotes.conn.sql("""select name,
|
||||||
|
(select count(*) from tabSessions where user=tabProfile.name
|
||||||
|
and timediff(now(), lastupdate) < time("01:00:00")) as has_session
|
||||||
|
from tabProfile
|
||||||
where ifnull(enabled,0)=1 and
|
where ifnull(enabled,0)=1 and
|
||||||
docstatus < 2 and
|
docstatus < 2 and
|
||||||
name not in ('Administrator', 'Guest')
|
name not in ('Administrator', 'Guest')
|
||||||
|
|||||||
@ -14,9 +14,9 @@
|
|||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
wn.require('lib/js/lib/jscolor/jscolor.js');
|
|
||||||
|
|
||||||
cur_frm.cscript.onload_post_render = function() {
|
cur_frm.cscript.onload_post_render = function() {
|
||||||
|
wn.require('lib/public/js/lib/jscolor/jscolor.js');
|
||||||
cur_frm.fields_dict.background_color.input.className = 'color';
|
cur_frm.fields_dict.background_color.input.className = 'color';
|
||||||
jscolor.bind();
|
jscolor.bind();
|
||||||
}
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user