[fixes] email digest
diff --git a/erpnext/accounts/utils.py b/erpnext/accounts/utils.py
index 07606be..ffb8a4c 100644
--- a/erpnext/accounts/utils.py
+++ b/erpnext/accounts/utils.py
@@ -84,7 +84,9 @@
 
 	if account:
 		acc = frappe.get_doc("Account", account)
-		acc.check_permission("read")
+
+		if not frappe.flags.ignore_account_permission:
+			acc.check_permission("read")
 
 		# for pl accounts, get balance within a fiscal year
 		if acc.report_type == 'Profit and Loss':
@@ -198,7 +200,7 @@
 	"""
 	jv_detail = jv_obj.get("accounts", {"name": d["voucher_detail_no"]})[0]
 	jv_detail.set(d["dr_or_cr"], d["allocated_amt"])
-	jv_detail.set('debit' if d['dr_or_cr']=='debit_in_account_currency' else 'credit', 
+	jv_detail.set('debit' if d['dr_or_cr']=='debit_in_account_currency' else 'credit',
 		d["allocated_amt"]*flt(jv_detail.exchange_rate))
 
 	original_reference_type = jv_detail.reference_type
@@ -212,7 +214,7 @@
 			select cost_center, balance, against_account, is_advance, account_type, exchange_rate
 			from `tabJournal Entry Account` where name = %s
 		""", d['voucher_detail_no'], as_dict=True)
-		
+
 		amount_in_account_currency = flt(d['unadjusted_amt']) - flt(d['allocated_amt'])
 		amount_in_company_currency = amount_in_account_currency * flt(jvd[0]['exchange_rate'])
 
@@ -225,14 +227,14 @@
 		ch.party = d["party"]
 		ch.cost_center = cstr(jvd[0]["cost_center"])
 		ch.balance = flt(jvd[0]["balance"])
-		
+
 		ch.set(d['dr_or_cr'], amount_in_account_currency)
 		ch.set('debit' if d['dr_or_cr']=='debit_in_account_currency' else 'credit', amount_in_company_currency)
-		
-		ch.set('credit_in_account_currency' if d['dr_or_cr']== 'debit_in_account_currency' 
+
+		ch.set('credit_in_account_currency' if d['dr_or_cr']== 'debit_in_account_currency'
 			else 'debit_in_account_currency', 0)
 		ch.set('credit' if d['dr_or_cr']== 'debit_in_account_currency' else 'debit', 0)
-		
+
 		ch.against_account = cstr(jvd[0]["against_account"])
 		ch.reference_type = original_reference_type
 		ch.reference_name = original_reference_name
diff --git a/erpnext/setup/doctype/email_digest/email_digest.js b/erpnext/setup/doctype/email_digest/email_digest.js
index 0d2ea14..9e3b4e6 100644
--- a/erpnext/setup/doctype/email_digest/email_digest.js
+++ b/erpnext/setup/doctype/email_digest/email_digest.js
@@ -23,22 +23,24 @@
 		});
 	}, "icon-eye-open", "btn-default");
 
-	cur_frm.add_custom_button(__('Send Now'), function() {
-		doc = locals[dt][dn];
-		if(doc.__unsaved != 1) {
-			return $c_obj(doc, 'send', '', function(r, rt) {
-				if(r.exc) {
-					msgprint(err_msg);
-					console.log(r.exc);
-				} else {
-					//console.log(arguments);
-					msgprint(__('Message Sent'));
-				}
-			});
-		} else {
-			msgprint(save_msg);
-		}
-	}, "icon-envelope", "btn-default");
+	if(user==="Administrator") {
+		cur_frm.add_custom_button(__('Send Now'), function() {
+			doc = locals[dt][dn];
+			if(doc.__unsaved != 1) {
+				return $c_obj(doc, 'send', '', function(r, rt) {
+					if(r.exc) {
+						msgprint(err_msg);
+						console.log(r.exc);
+					} else {
+						//console.log(arguments);
+						msgprint(__('Message Sent'));
+					}
+				});
+			} else {
+				msgprint(save_msg);
+			}
+		}, "icon-envelope", "btn-default");
+	}
 }
 
 cur_frm.cscript.addremove_recipients = function(doc, dt, dn) {
diff --git a/erpnext/setup/doctype/email_digest/email_digest.py b/erpnext/setup/doctype/email_digest/email_digest.py
index 1dc3171..e62ff0f 100644
--- a/erpnext/setup/doctype/email_digest/email_digest.py
+++ b/erpnext/setup/doctype/email_digest/email_digest.py
@@ -69,6 +69,8 @@
 
 	def get_msg_html(self):
 		"""Build email digest content"""
+		frappe.flags.ignore_account_permission = True
+
 		context = frappe._dict()
 		context.update(self.__dict__)
 
@@ -84,6 +86,8 @@
 		if not (context.events or context.todo_list or context.notifications or context.cards):
 			return None
 
+		frappe.flags.ignore_account_permission = False
+
 		# style
 		return frappe.render_template("erpnext/setup/doctype/email_digest/templates/default.html",
 			context, is_path=True)
@@ -103,11 +107,13 @@
 	def set_style(self, context):
 		"""Set standard digest style"""
 		context.text_muted = '#8D99A6'
-		context.h1 = 'margin-bottom: 30px; margin-bottom: 0'
+		context.text_color = '#36414C'
+		context.h1 = 'margin-bottom: 30px; margin-bottom: 0; margin-top: 40px; font-weight: 400;'
 		context.label_css = '''display: inline-block; color: {text_muted};
 			padding: 3px 7px; margin-right: 7px;'''.format(text_muted = context.text_muted)
-		context.section_head = 'margin-top: 60px;'
-		context.line_item  = 'padding: 7px 0px; margin: 0; border-bottom: 1px solid #d1d8dd;'
+		context.section_head = 'margin-top: 60px; font-size: 16px;'
+		context.line_item  = 'padding: 5px 0px; margin: 0; border-bottom: 1px solid #d1d8dd;'
+		context.link_css = 'color: {text_color}; text-decoration: none;'.format(text_color = context.text_color)
 
 
 	def get_notifications(self):
@@ -154,25 +160,35 @@
 	def set_accounting_cards(self, context):
 		"""Create accounting cards if checked"""
 
+		cache = frappe.cache()
 		context.cards = []
 		for key in ("income", "expenses_booked", "income_year_to_date", "expense_year_to_date",
 			"invoiced_amount", "payables", "bank_balance"):
 			if self.get(key):
-				card = frappe._dict(getattr(self, "get_" + key)())
+				cache_key = "email_digest:card:" + key
+				card = cache.get(cache_key)
 
-				# format values
-				if card.last_value:
-					card.diff = int(flt(card.value - card.last_value) / card.last_value * 100)
-					if card.diff < 0:
-						card.diff = str(card.diff)
-						card.gain = False
-					else:
-						card.diff = "+" + str(card.diff)
-						card.gain = True
+				if card:
+					card = eval(card)
 
-					card.last_value = self.fmt_money(card.last_value)
+				else:
+					card = frappe._dict(getattr(self, "get_" + key)())
 
-				card.value = self.fmt_money(card.value)
+					# format values
+					if card.last_value:
+						card.diff = int(flt(card.value - card.last_value) / card.last_value * 100)
+						if card.diff < 0:
+							card.diff = str(card.diff)
+							card.gain = False
+						else:
+							card.diff = "+" + str(card.diff)
+							card.gain = True
+
+						card.last_value = self.fmt_money(card.last_value)
+
+					card.value = self.fmt_money(card.value)
+
+					cache.setex(cache_key, card, 24 * 60 * 60)
 
 				context.cards.append(card)
 
diff --git a/erpnext/setup/doctype/email_digest/templates/default.html b/erpnext/setup/doctype/email_digest/templates/default.html
index 460e8fa..c836c46 100644
--- a/erpnext/setup/doctype/email_digest/templates/default.html
+++ b/erpnext/setup/doctype/email_digest/templates/default.html
@@ -1,9 +1,9 @@
 {% macro show_card(card) %}
-<div style="width: 50%; float:left; min-height: 120px; padding-top: 20px;">
-    <h6 style="color: {{ text_muted }}">{{ card.label }}</h6>
-    <h4>{{ card.value }}</h4>
+<div style="width: 50%; float:left; min-height: 80px; padding-top: 20px;">
+    <h6 style="color: {{ text_muted }}; font-size: 12px; margin-bottom: 0px; margin-top: 0px;">{{ card.label }}</h6>
+    <h4 style="margin-top: 7px; font-size: 16px;">{{ card.value }}</h4>
     {% if card.diff %}
-    <p style="color: {{ text_muted }}">{{ card.diff }}%</p>
+    <p style="color: {{ text_muted }}; font-size: 12px;">{{ card.diff }}%</p>
     {% endif %}
 </div>
 {% endmacro %}
@@ -12,7 +12,7 @@
 
 {% if cards %}
 <h1 style="{{ h1 }}">{{ title }}</h1>
-<h4 style="font-weight: normal; color: {{ text_muted }}; margin-top: 7px">
+<h4 style="font-weight: normal; color: {{ text_muted }}; margin-top: 7px; font-size: 16px; margin-top: 7px;">
     <p>{% if frequency == "Daily "%}
         {{ frappe.format_date(future_from_date) }}
     {% else %}
@@ -31,6 +31,7 @@
 {% endif %}
 
 
+{% if events or todo_list or notifications %}
 <h1 style="{{ h1 }}">{{ _("Pending Activities") }}</h1>
 
 <!-- events -->
@@ -45,7 +46,7 @@
         <table style="width: 100%;">
             <tr>
                 <td>
-                    <a href="{{ e.link }}">{{ e.subject }}</a>
+                    <a style="{{ link_css }}" href="{{ e.link }}">{{ e.subject }}</a>
                 </td>
                 <td style="width: 40%; text-align: right">
                     <span style="{{ label_css }}">
@@ -72,7 +73,7 @@
         <table style="width: 100%;">
             <tr>
                 <td>
-                    <a href="{{ t.link }}">{{ t.description }}</a>
+                    <a style="{{ link_css }}" href="{{ t.link }}">{{ t.description }}</a>
                 </td>
                 <td style="width: 25%; text-align: right">
                     <span style="{{ label_css }}">
@@ -95,7 +96,7 @@
         <table style="width: 100%;">
             <tr>
                 <td>
-                    <a href="n.link">{{ n.key }}</a>
+                    <a style="{{ link_css }}" href="{{ n.link }}">{{ n.key }}</a>
                 </td>
                 <td style="width: 25%; text-align: right">
                     <span style="{{ label_css }}">
@@ -109,3 +110,5 @@
 </div>
 {% endif %}
 </div>
+
+{% endif %}