Merge branch 'stable' of github.com:webnotes/erpnext into stable
diff --git a/home/page/my_company/my_company.js b/home/page/my_company/my_company.js
index 8b1b44f..0850607 100644
--- a/home/page/my_company/my_company.js
+++ b/home/page/my_company/my_company.js
@@ -143,7 +143,10 @@
 			var c1 = repl(' AND (first_name LIKE "%(txt)s" OR last_name LIKE "%(txt)s" OR name LIKE "%(txt)s")', {txt:'%' + me.search_inp.value + '%'});
 		}
 		
-		this.query = repl("SELECT distinct ifnull(name,''), ifnull(concat_ws(' ', first_name, last_name),''), ifnull(messanger_status,''), ifnull(gender,''), ifnull(file_list,''), 0, enabled from tabProfile where docstatus != 2 AND name not in ('Guest','Administrator') %(cond)s ORDER BY name asc",{cond:c1});
+		this.query = repl("SELECT distinct ifnull(name,''), ifnull(concat_ws(' ', first_name, last_name),''), \
+			ifnull(messanger_status,''), ifnull(gender,''), ifnull(file_list,''), 0, enabled, last_login \
+			from tabProfile where docstatus != 2 AND name not in ('Guest','Administrator') %(cond)s \
+			ORDER BY name asc",{cond:c1});
 	}
 	this.lst.make(this.lst_area);
 	this.lst.show_cell= function(cell, ri, ci, d) {
diff --git a/master.sql.gz b/master.sql.gz
index 05fc390..273277e 100644
--- a/master.sql.gz
+++ b/master.sql.gz
Binary files differ
diff --git a/patches/patch.py b/patches/patch.py
index f184197..384ee2a 100644
--- a/patches/patch.py
+++ b/patches/patch.py
@@ -1,7 +1,7 @@
 # REMEMBER to update this
 # ========================
 
-last_patch = 325
+last_patch = 326
 
 #-------------------------------------------
 
@@ -1294,3 +1294,7 @@
 	elif patch_no == 325:
 		sql("update `tabDocField` set fieldtype = 'Data' where parent = 'Salary Slip' and fieldname = 'total_days_in_month'")
 		reload_doc('hr', 'doctype', 'salary_slip')
+	elif patch_no == 326:
+		# load the new billing page
+		if cint(webnotes.conn.get_value('Control Panel',None,'sync_with_gateway')):
+			reload_doc('server_tools','page','billing')
diff --git a/setup/doctype/company/company.js b/setup/doctype/company/company.js
index e27052c..c82b95c 100644
--- a/setup/doctype/company/company.js
+++ b/setup/doctype/company/company.js
@@ -2,6 +2,32 @@
   if(doc.abbr && !doc.__islocal) set_field_permlevel('abbr',1);
 }
 
+cur_frm.cscript.has_special_chars = function(t) {
+  var iChars = "!@#$%^*+=-[]\\\';,/{}|\":<>?";
+  for (var i = 0; i < t.length; i++) {
+    if (iChars.indexOf(t.charAt(i)) != -1) {
+      return true;
+    }
+  }
+  return false;
+}
+
+cur_frm.cscript.company_name = function(doc){
+  if(doc.company_name && cur_frm.cscript.has_special_chars(doc.company_name)){   
+    msgprint("<font color=red>Special Characters <b>! @ # $ % ^ * + = - [ ] ' ; , / { } | : < > ?</b> are not allowed for</font>\nCompany Name <b>" + doc.company_name +"</b>")        
+    doc.company_name = '';
+    refresh_field('company_name');
+  }
+}
+
+cur_frm.cscript.abbr = function(doc){
+  if(doc.abbr && cur_frm.cscript.has_special_chars(doc.abbr)){   
+    msgprint("<font color=red>Special Characters <b>! @ # $ % ^ * + = - [ ] ' ; , / { } | : < > ?</b> are not allowed for</font>\nAbbr <b>" + doc.abbr +"</b>")        
+    doc.abbr = '';
+    refresh_field('abbr');
+  }
+}
+
 cur_frm.fields_dict.default_bank_account.get_query = function(doc) {    
   return 'SELECT `tabAccount`.name, `tabAccount`.debit_or_credit, `tabAccount`.group_or_ledger FROM `tabAccount` WHERE `tabAccount`.company = "'+doc.name+'" AND `tabAccount`.group_or_ledger = "Ledger" AND `tabAccount`.docstatus != 2 AND `tabAccount`.account_type = "Bank or Cash" AND `tabAccount`.%(key)s LIKE "%s" ORDER BY `tabAccount`.name LIMIT 50';   
 }
diff --git a/setup/doctype/setup_control/setup_control.py b/setup/doctype/setup_control/setup_control.py
index e01e60a..61e3a82 100644
--- a/setup/doctype/setup_control/setup_control.py
+++ b/setup/doctype/setup_control/setup_control.py
@@ -13,7 +13,6 @@
 get_value = webnotes.conn.get_value
 in_transaction = webnotes.conn.in_transaction
 convert_to_lists = webnotes.conn.convert_to_lists
-
 	
 # -----------------------------------------------------------------------------------------
 
@@ -37,9 +36,11 @@
 	#-----------------------
 	def set_account_details(self, args):
 		args = eval(args)
-		#webnotes.logger.error("args in set_account_details of setup_control: " + str(args))
+
 		self.set_cp_defaults(args['company'], args['industry'], args['time_zone'], args['country'], args['account_name'])
 		self.create_profile(args['user'], args['first_name'], args['last_name'])	
+	
+		from server_tools.gateway_utils import update_client_control
 		update_client_control(args['total_users'])
 		
 	
@@ -182,7 +183,7 @@
 		Validates if setup has been performed after database allocation
 		"""
 
-		from server_tools.gateway_utils import update_client_control, get_total_users
+		from server_tools.gateway_utils import get_total_users
 		
 		args = eval(args)
 		#webnotes.logger.error("args in set_account_details of setup_control: " + str(args))
diff --git a/startup/event_handlers.py b/startup/event_handlers.py
index 2bd8fae..53b979e 100644
--- a/startup/event_handlers.py
+++ b/startup/event_handlers.py
@@ -33,7 +33,7 @@
 		webnotes.conn.set_global('days_to_expiry', webnotes.form_dict.get('days_to_expiry'))
 
 	if webnotes.form_dict.get('first_name'):
-		from server_tools.server_tools.gateway_utils import update_user_details
+		from server_tools.gateway_utils import update_user_details
 		update_user_details()
 		
 #
@@ -43,6 +43,7 @@
 	# login from
 	if webnotes.form_dict.get('login_from'):
 		webnotes.session['data']['login_from'] = webnotes.form.getvalue('login_from')
+		webnotes.session_obj.update()
 
 	update_account_details()
 
@@ -51,7 +52,7 @@
 #
 def on_logout(login_manager):
 	if cint(webnotes.conn.get_value('Control Panel', None, 'sync_with_gateway')):
-		from server_tools.server_tools.gateway_utils import logout_sso
+		from server_tools.gateway_utils import logout_sso
 		logout_sso()
 
 #
diff --git a/startup/startup.css b/startup/startup.css
index f4fd39e..67393aa 100644
--- a/startup/startup.css
+++ b/startup/startup.css
@@ -2,7 +2,7 @@
 	background-color: #e2e2e2;
 }
 
-div.layout_wrapper {
+.layout_wrapper {
 	padding: 13px;
 	margin: 7px;
 	-moz-box-shadow: 1px 1px 6px #AAA;
diff --git a/startup/startup.js b/startup/startup.js
index a93906c..1280e0f 100644
--- a/startup/startup.js
+++ b/startup/startup.js
@@ -46,11 +46,11 @@
 	// for logout and payment
 	var callback = function(r,rt) {
 		if(r.message){
-			login_file = r.message;
+			login_file = 'http://' + r.message;
 		}
 		else {
 			
-			login_file = 'https://www.erpnext.com';
+			login_file = 'http://www.erpnext.com';
 			}
 		// setup toolbar
 		pscript.startup_setup_toolbar();
diff --git a/utilities/doctype/sms_control/sms_control.py b/utilities/doctype/sms_control/sms_control.py
index de11e90..a1edf83 100644
--- a/utilities/doctype/sms_control/sms_control.py
+++ b/utilities/doctype/sms_control/sms_control.py
@@ -58,7 +58,7 @@
 	def connect_gateway(self):
 		"login to gateway"
 		from webnotes.utils.webservice import FrameworkServer
-		fw = FrameworkServer('www.erpnext.com','/','__system@webnotestech.com','password',https=1)
+		fw = FrameworkServer('www.erpnext.com', '/', '__system@webnotestech.com', 'password', https=1)
 		return fw
 
 	def get_sender_name(self):