Merge branch 'master' of github.com:webnotes/erpnext into edge
diff --git a/hr/search_criteria/monthly_attendance_details/monthly_attendance_details.sql b/hr/search_criteria/monthly_attendance_details/monthly_attendance_details.sql
index 7487fb4..762a94f 100644
--- a/hr/search_criteria/monthly_attendance_details/monthly_attendance_details.sql
+++ b/hr/search_criteria/monthly_attendance_details/monthly_attendance_details.sql
@@ -1 +1 @@
-SELECT DISTINCT `tabAttendance`.employee, `tabAttendance`.employee_name FROM `tabAttendance` WHERE `tabAttendance`.fiscal_year like '%(fiscal_year)s%%' AND `tabAttendance`.`company` like '%(company)s%%' AND `tabAttendance`.`employee` like '%(employee)s%%'
\ No newline at end of file
+SELECT DISTINCT `tabAttendance`.employee, `tabEmployee`.employee_name FROM `tabAttendance`, `tabEmployee` WHERE `tabEmployee`.name = `tabAttendance`.employee and `tabAttendance`.fiscal_year like '%(fiscal_year)s%%' AND `tabAttendance`.company like '%(company)s%%' AND `tabAttendance`.employee like '%(employee)s%%'
\ No newline at end of file
diff --git a/patches/february_2013/p07_clear_web_cache.py b/patches/february_2013/p07_clear_web_cache.py
deleted file mode 100644
index 2632924..0000000
--- a/patches/february_2013/p07_clear_web_cache.py
+++ /dev/null
@@ -1,6 +0,0 @@
-import webnotes
-
-def execute():
-	webnotes.reload_doc("website", "doctype", "blog_post")
-	from website.utils import clear_cache
-	clear_cache()
diff --git a/patches/patch_list.py b/patches/patch_list.py
index 7409c0e..5a504f8 100644
--- a/patches/patch_list.py
+++ b/patches/patch_list.py
@@ -189,7 +189,6 @@
 	"execute:webnotes.delete_doc('DocType', 'Service Order Detail')",
 	"execute:webnotes.delete_doc('DocType', 'Service Quotation Detail')",
 	"patches.february_2013.p06_material_request_mappers",
-	"patches.february_2013.p07_clear_web_cache",
 	"execute:webnotes.delete_doc('Page', 'Query Report')",
 	"execute:webnotes.delete_doc('Search Criteria', 'employeewise_balance_leave_report')",
 	"execute:webnotes.delete_doc('Search Criteria', 'employee_leave_balance_report')",
@@ -211,6 +210,7 @@
 	"execute:webnotes.conn.sql('update tabDocPerm set `submit`=1, `cancel`=1, `amend`=1 where parent=\"Time Log\"')",
 	"execute:webnotes.delete_doc('DocType', 'Attendance Control Panel')",
 	"patches.march_2013.p02_get_global_default",
-	"execute:webnotes.bean('Style Settings', 'Style Settings').save()",
 	"patches.march_2013.p03_rename_blog_to_blog_post",
+	"execute:webnotes.bean('Style Settings', 'Style Settings').save()",
+	"execute:webnotes.reload_doc('hr', 'search_criteria', 'monthly_attendance_details')",
 ]
\ No newline at end of file
diff --git a/stock/utils.py b/stock/utils.py
index 20d08ea..bf5e2f9 100644
--- a/stock/utils.py
+++ b/stock/utils.py
@@ -171,7 +171,7 @@
 		buying_amount = 0.0
 		for bom_item in item_sales_bom[item_code]:
 			buying_amount += _get_buying_amount(voucher_type, voucher_no, "[** No Item Row **]",
-				item_code, warehouse, bom_item.qty * qty, stock_ledger_entries)
+				bom_item.item_code, warehouse, bom_item.qty * qty, stock_ledger_entries)
 		return buying_amount
 	else:
 		# doesn't have sales bom
@@ -188,13 +188,13 @@
 				abs(flt(sle.qty)) == qty):
 					buying_amount = flt(stock_ledger_entries[i+1].stock_value) - \
 						flt(sle.stock_value)
-
 					return buying_amount
-					
 	return 0.0
 
 def get_sales_bom():
 	item_sales_bom = {}
+	# for r in webnotes.conn.sql("""select parent_item, item_code, qty, warehouse, voucher_detail_no
+	# 	from `tabDelivery Note Packing Item` where docstatus = 1""", as_dict=1):
 	for r in webnotes.conn.sql("""select parent, item_code, qty from `tabSales BOM Item`""",
 	 	as_dict=1):
 			item_sales_bom.setdefault(r.parent, []).append(r)
diff --git a/website/doctype/style_settings/style_settings.py b/website/doctype/style_settings/style_settings.py
index bf46afb..91ca0a5 100644
--- a/website/doctype/style_settings/style_settings.py
+++ b/website/doctype/style_settings/style_settings.py
@@ -53,13 +53,15 @@
 				del self.doc.fields[f]
 	
 	def validate_colors(self):
-		if self.doc.page_background==self.doc.page_text:
-			webnotes.msgprint(_("Page text and background is same color. Please change."),
-				raise_exception=1)
+		if (self.doc.page_background or self.doc.page_text) and \
+			self.doc.page_background==self.doc.page_text:
+				webnotes.msgprint(_("Page text and background is same color. Please change."),
+					raise_exception=1)
 
-		if self.doc.top_bar_background==self.doc.top_bar_foreground:
-			webnotes.msgprint(_("Top Bar text and background is same color. Please change."),
-				raise_exception=1)
+		if (self.doc.top_bar_background or self.doc.top_bar_foreground) and \
+			self.doc.top_bar_background==self.doc.top_bar_foreground:
+				webnotes.msgprint(_("Top Bar text and background is same color. Please change."),
+					raise_exception=1)
 
 	
 	def prepare(self):
diff --git a/website/helpers/blog.py b/website/helpers/blog.py
index 5ee3451..1f25ac0 100644
--- a/website/helpers/blog.py
+++ b/website/helpers/blog.py
@@ -83,7 +83,7 @@
 	
 	# notify commentors 
 	commentors = [d[0] for d in webnotes.conn.sql("""select comment_by from tabComment where
-		comment_doctype='Blog' and comment_docname=%s and
+		comment_doctype='Blog Post' and comment_docname=%s and
 		ifnull(unsubscribed, 0)=0""", args.get('comment_docname'))]
 	
 	blog = webnotes.conn.sql("""select * from `tabBlog Post` where name=%s""", 
diff --git a/website/templates/js/blog.js b/website/templates/js/blog.js
index 61e1b65..fd5a156 100644
--- a/website/templates/js/blog.js
+++ b/website/templates/js/blog.js
@@ -64,7 +64,9 @@
 				b.comment_text = '1 comment.'
 			} else {
 				b.comment_text = b.comments + ' comments.'
-			} 
+			}
+			
+			b.page_name = encodeURIComponent(b.page_name);
 			
 			$(repl('<div class="row">\
 					<div class="span1">\
diff --git a/website/templates/js/blog_page.js b/website/templates/js/blog_page.js
index d5e9970..efdd6bc 100644
--- a/website/templates/js/blog_page.js
+++ b/website/templates/js/blog_page.js
@@ -36,7 +36,7 @@
 			comment_by: $("[name='comment_by']").val(),
 			comment: $("[name='comment']").val(),
 			cmd: "website.helpers.blog.add_comment",
-			comment_doctype: "Blog",
+			comment_doctype: "Blog Post",
 			comment_docname: "{{ name }}",
 			page_name: "{{ page_name }}",
 			_type: "POST"