redesigned scheduler
diff --git a/erpnext/patches/jan_mar_2012/navupdate.py b/erpnext/patches/jan_mar_2012/navupdate.py
new file mode 100644
index 0000000..0ba21e9
--- /dev/null
+++ b/erpnext/patches/jan_mar_2012/navupdate.py
@@ -0,0 +1,20 @@
+import webnotes
+
+def execute():
+	from webnotes.modules import reload_doc
+	reload_doc('accounts', 'page', 'accounts_home')
+	reload_doc('selling', 'page', 'selling_home')
+	reload_doc('buying', 'page', 'buying_home')
+	reload_doc('stock', 'page', 'stock_home')
+	reload_doc('hr', 'page', 'hr_home')
+	reload_doc('support', 'page', 'support_home')
+	reload_doc('production', 'page', 'production_home')
+	reload_doc('projects', 'page', 'projects_home')
+	reload_doc('website', 'page', 'website_home')
+	
+	webnotes.conn.commit()
+	webnotes.conn.sql("""create table __SchedulerLog (
+		`timestamp` timestamp,
+		method varchar(200),
+		error text
+	) engine=MyISAM""")
\ No newline at end of file
diff --git a/erpnext/setup/doctype/email_digest/email_digest.py b/erpnext/setup/doctype/email_digest/email_digest.py
index e391d37..3bc5e64 100644
--- a/erpnext/setup/doctype/email_digest/email_digest.py
+++ b/erpnext/setup/doctype/email_digest/email_digest.py
@@ -783,7 +783,7 @@
 			send_date = dt_dict['server_dt'].date()
 			send_time = dt_dict['server_dt'].time()
 
-			if (now_date == send_date) and (send_time <= now_time):
+			if (now_date == send_date):
 				#webnotes.msgprint('sending ' + ed_obj.doc.name)
 				ed_obj.send()
 			#else:
diff --git a/erpnext/startup/schedule_handlers.py b/erpnext/startup/schedule_handlers.py
new file mode 100644
index 0000000..49ee615
--- /dev/null
+++ b/erpnext/startup/schedule_handlers.py
@@ -0,0 +1,13 @@
+"""will be called by scheduler"""
+
+import webnotes
+	
+def execute_all():
+	"""get support email"""
+	from support.doctype.support_ticket import get_support_mails
+	get_support_mails()
+	
+def execute_daily():
+	"""email digest"""
+	from setup.doctype.email_digest.email_digest import send
+	send()
\ No newline at end of file
diff --git a/wnf.py b/wnf.py
index e137746..edbf146 100755
--- a/wnf.py
+++ b/wnf.py
@@ -23,13 +23,18 @@
 def setup_options():
 	from optparse import OptionParser
 	parser = OptionParser()
+
+	parser.add_option("-d", "--db",
+						dest="db_name",
+						help="Apply the patches on given db")
+
+	# build
 	parser.add_option("-b", "--build", default=False, action="store_true",
 						help="minify + concat js files")
 	parser.add_option("-c", "--clear", default=False, action="store_true",
 						help="increment version")
-	parser.add_option("--replace", nargs=3, default=False, 
-						metavar = "search replace_by extension",
-						help="file search-replace")
+
+	# git
 	parser.add_option("--status", default=False, action="store_true",
 						help="git status")
 	parser.add_option("--pull", nargs=2, default=False,
@@ -41,28 +46,43 @@
 	parser.add_option("-l", "--latest",
 						action="store_true", dest="run_latest", default=False,
 						help="Apply the latest patches")
+
+	# patch
 	parser.add_option("-p", "--patch", nargs=1, dest="patch_list", metavar='patch_module',
 						action="append",
 						help="Apply patch")
 	parser.add_option("-f", "--force",
 						action="store_true", dest="force", default=False,
 						help="Force Apply all patches specified using option -p or --patch")
-	parser.add_option("-d", "--db",
-						dest="db_name",
-						help="Apply the patches on given db")
 	parser.add_option('--reload_doc', nargs=3, metavar = "module doctype docname",
 						help="reload doc")
 	parser.add_option('--export_doc', nargs=2, metavar = "doctype docname",
 						help="export doc")
+
+	# install
 	parser.add_option('--install', nargs=3, metavar = "rootpassword dbname source",
 						help="install fresh db")
 	parser.add_option('--sync_with_gateway', nargs=1, metavar = "1/0", \
 						help="Set or Unset Sync with Gateway")
+
+	# diff
 	parser.add_option('--diff_ref_file', nargs=0, \
 						help="Get missing database records and mismatch properties, with file as reference")
 	parser.add_option('--diff_ref_db', nargs=0, \
 						help="Get missing .txt files and mismatch properties, with database as reference")
 
+	# scheduler
+	parser.add_option('--run_scheduler', default=False, action="store_true",
+						help="Trigger scheduler")
+	parser.add_option('--run_scheduler_event', nargs=1, metavar="[all|daily|weekly|monthly]",
+						help="Run scheduler event")
+
+	# misc
+	parser.add_option("--replace", nargs=3, default=False, 
+						metavar = "search replace_by extension",
+						help="file search-replace")
+	
+
 	return parser.parse_args()
 	
 def run():
@@ -165,6 +185,14 @@
 		import webnotes.modules.diff
 		webnotes.modules.diff.diff_ref_db()
 	
+	elif options.run_scheduler:
+		import webnotes.utils.scheduler
+		print webnotes.utils.scheduler.execute()
+	
+	elif options.run_scheduler_event is not None:
+		import webnotes.utils.scheduler
+		print webnotes.utils.scheduler.trigger('execute_' + options.run_scheduler_event)
+	
 	# print messages
 	if webnotes.message_log:
 		print '\n'.join(webnotes.message_log)