no role access for financial analytics

This commit is contained in:
Rushabh Mehta 2012-09-28 10:23:27 +05:30
parent b02744de8f
commit 224714c248
3 changed files with 20 additions and 12 deletions

View File

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

View File

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

View File

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