Redesigned templates. Now all templates must be inside templates/pages templates/generators
diff --git a/erpnext/templates/pages/__init__.py b/erpnext/templates/pages/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/erpnext/templates/pages/__init__.py
diff --git a/erpnext/templates/pages/address.html b/erpnext/templates/pages/address.html
new file mode 100644
index 0000000..5eaefd5
--- /dev/null
+++ b/erpnext/templates/pages/address.html
@@ -0,0 +1,114 @@
+{% extends base_template %}
+
+{% set title=doc and doc.name or "New Address" %}
+{% set docname=(doc and doc.name or "") %}
+
+{% macro render_fields(docfields) -%}
+{% for df in docfields -%}
+	{% if df.fieldtype in ["Data", "Link"] -%}
+	<fieldset>
+		<label>{{ df.label }}</label>
+		<input class="form-control" type="text" placeholder="Type {{ df.label }}" 
+			data-fieldname="{{ df.fieldname }}" data-fieldtype="{{ df.fieldtype }}"
+			{% if doc and doc.fields.get(df.fieldname) -%} value="{{ doc.fields[df.fieldname] }}" {%- endif %}>
+	</fieldset>
+	{% elif df.fieldtype == "Check" -%}
+	<fieldset class="checkbox">
+		<label><input type="checkbox" data-fieldname="{{ df.fieldname }}" 
+			data-fieldtype="{{ df.fieldtype }}" 
+			{% if doc and cint(doc.fields.get(df.fieldname)) -%} checked="checked" {%- endif %}> 
+			{{ df.label }}</label>
+	</fieldset>
+	{% elif df.fieldtype == "Select" -%}
+	<fieldset>
+		<label>{{ df.label }}</label>
+		<select class="form-control" data-fieldname="{{ df.fieldname }}" data-fieldtype="{{ df.fieldtype }}">
+			{% for value in df.options.split("\n") -%}
+			{% if doc and doc.fields.get(df.fieldname) == value -%}
+			<option selected="selected">{{ value }}</option>
+			{% else -%}
+			<option>{{ value }}</option>
+			{%- endif %}
+			{%- endfor %}
+		</select>
+	</fieldset>
+	{%- endif %}
+{%- endfor %}
+{%- endmacro %}
+
+{% block content %}
+<div class="container content">
+    <ul class="breadcrumb">
+    	<li><a href="index">Home</a></li>
+    	<li><a href="addresses">My Addresses</a></li>
+    	<li class="active"><i class="icon-map-marker icon-fixed-width"></i> {{ title }}</li>
+    </ul>
+	<h3><i class="icon-map-marker icon-fixed-width"></i> {{ title }}</h3>
+	<button type="button" class="btn btn-primary pull-right" id="address-save"><i class="icon-ok"></i> 
+		{{ doc and "Save" or "Insert" }}</button>
+	<div class="clearfix"></div>
+	<hr>
+	<div id="address-error" class="alert alert-danger" style="display: none;"></div>
+	<form autocomplete="on">
+		<div class="row">
+			<section class="col-md-6">
+				{{ render_fields(meta.left_fields) }}
+			</section>
+			<section class="col-md-6">
+				{{ render_fields(meta.right_fields) }}
+			</section>
+		</section>
+	</form>
+</div>
+
+<script>
+;(function() {
+	$(document).ready(function() {
+		bind_save();
+	});
+	
+	var bind_save = function() {
+		$("#address-save").on("click", function() {
+			var fields = {
+				name: "{{ docname }}"
+			};
+
+			$("form").find("[data-fieldname]").each(function(i, input) {
+				var $input = $(input);
+				var fieldname = $(input).attr("data-fieldname");
+				var fieldtype = $(input).attr("data-fieldtype");
+				
+				if(fieldtype == "Check") {
+					fields[fieldname] = $input.is(":checked") ? 1 : 0;
+				} else {
+					fields[fieldname] = $input.val();
+				}
+			});
+			
+			wn.call({
+				btn: $(this),
+				type: "POST",
+				method: "selling.utils.cart.save_address",
+				args: { fields: fields, address_fieldname: get_url_arg("address_fieldname") },
+				callback: function(r) {
+					if(r.exc) {
+						var msg = "";
+						if(r._server_messages) {
+							msg = JSON.parse(r._server_messages || []).join("<br>");
+						}
+						
+						$("#address-error")
+							.html(msg || "Something went wrong!")
+							.toggle(true);
+					} else if(get_url_arg("address_fieldname")) {
+						window.location.href = "cart";
+					} else {
+						window.location.href = "address?name=" + encodeURIComponent(r.message);
+					}
+				}
+			});
+		});
+	};
+})();
+</script>
+{% endblock %}
\ No newline at end of file
diff --git a/erpnext/templates/pages/address.py b/erpnext/templates/pages/address.py
new file mode 100644
index 0000000..9918e5f
--- /dev/null
+++ b/erpnext/templates/pages/address.py
@@ -0,0 +1,30 @@
+# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
+# License: GNU General Public License v3. See license.txt
+
+from __future__ import unicode_literals
+import webnotes
+from webnotes.utils import cint
+
+no_cache = True
+
+def get_context():
+	def _get_fields(fieldnames):
+		return [webnotes._dict(zip(["label", "fieldname", "fieldtype", "options"], 
+				[df.label, df.fieldname, df.fieldtype, df.options]))
+			for df in webnotes.get_doctype("Address", processed=True).get({"fieldname": ["in", fieldnames]})]
+	
+	bean = None
+	if webnotes.form_dict.name:
+		bean = webnotes.bean("Address", webnotes.form_dict.name)
+	
+	return {
+		"doc": bean.doc if bean else None,
+		"meta": webnotes._dict({
+			"left_fields": _get_fields(["address_title", "address_type", "address_line1", "address_line2",
+				"city", "state", "pincode", "country"]),
+			"right_fields": _get_fields(["email_id", "phone", "fax", "is_primary_address",
+				"is_shipping_address"])
+		}),
+		"cint": cint
+	}
+	
diff --git a/erpnext/templates/pages/addresses.html b/erpnext/templates/pages/addresses.html
new file mode 100644
index 0000000..6fe36a9
--- /dev/null
+++ b/erpnext/templates/pages/addresses.html
@@ -0,0 +1,51 @@
+{% extends base_template %}
+
+{% set title="My Addresses" %}
+
+{% block content %}
+<div class="container content">
+    <ul class="breadcrumb">
+    	<li><a href="index">Home</a></li>
+    	<li class="active"><i class="icon-map-marker icon-fixed-width"></i> My Addresses</li>
+    </ul>
+	<p><a class="btn btn-default" href="address"><i class="icon-plus"> New Address</i></a></p>
+	<hr>
+	<div id="address-list">
+		<div class="progress progress-striped active">
+			<div class="progress-bar progress-bar-info" style="width: 100%;"></div>
+		</div>
+	</div>
+</div>
+
+<script>
+;(function() {
+	$(document).ready(function() {
+		fetch_addresses();
+	});
+	
+	var fetch_addresses = function() {
+		wn.call({
+			method: "selling.utils.cart.get_addresses",
+			callback: function(r) {
+				$("#address-list .progress").remove();
+				var $list = $("#address-list");
+			
+				if(!(r.message && r.message.length)) {
+					$list.html("<div class='alert'>No Addresses Found</div>");
+					return;
+				}
+			
+				$.each(r.message, function(i, address) {
+					address.url_name = encodeURIComponent(address.name);
+					$(repl('<div> \
+						<p><a href="address?name=%(url_name)s">%(name)s</a></p> \
+						<p>%(display)s</p> \
+						<hr> \
+					</div>', address)).appendTo($list);
+				});
+			}
+		});
+	};
+})();
+</script>
+{% endblock %}
\ No newline at end of file
diff --git a/erpnext/templates/pages/addresses.py b/erpnext/templates/pages/addresses.py
new file mode 100644
index 0000000..41f6b56
--- /dev/null
+++ b/erpnext/templates/pages/addresses.py
@@ -0,0 +1,6 @@
+# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
+# License: GNU General Public License v3. See license.txt
+
+from __future__ import unicode_literals
+
+no_cache = True
\ No newline at end of file
diff --git a/erpnext/templates/pages/cart.html b/erpnext/templates/pages/cart.html
new file mode 100644
index 0000000..8aae9d9
--- /dev/null
+++ b/erpnext/templates/pages/cart.html
@@ -0,0 +1,57 @@
+{% extends base_template %}
+
+{% block javascript %}
+<script>{% include "templates/includes/cart.js" %}</script>
+{% endblock %}
+
+{% set title="Shopping Cart" %}
+
+{% block content %}
+<div class="container content">
+	<h2><i class="icon-shopping-cart"></i> {{ title }}</h2>
+	<div class="progress progress-striped active">
+		<div class="progress-bar progress-bar-info" style="width: 100%;"></div>
+	</div>
+	<div id="cart-container" class="hide">
+		<p class="pull-right"><button class="btn btn-success btn-place-order" type="button">Place Order</button></p>
+		<div class="clearfix"></div>
+		<div id="cart-error" class="alert alert-danger" style="display: none;"></div>
+		<hr>
+		<div class="row">
+			<div class="col-md-9 col-sm-9">
+				<div class="row">
+					<div class="col-md-9 col-md-offset-3"><h4>Item Details</h4></div>
+				</div>
+			</div>
+			<div class="col-md-3 col-sm-3 text-right"><h4>Qty, Amount</h4></div>
+		</div><hr>
+		<div id="cart-items">
+		</div>
+		<div id="cart-taxes">
+		</div>
+		<div id="cart-totals">
+		</div>
+		<hr>
+		<div id="cart-addresses">
+			<div class="row">
+				<div class="col-md-6">
+					<h4>Shipping Address</h4>
+					<div id="cart-shipping-address" class="panel-group" 
+						data-fieldname="shipping_address_name"></div>
+					<button class="btn btn-default" type="button" id="cart-add-shipping-address">
+						<span class="icon icon-plus"></span> New Shipping Address</button>
+				</div>
+				<div class="col-md-6">
+					<h4>Billing Address</h4>
+					<div id="cart-billing-address" class="panel-group"
+						data-fieldname="customer_address"></div>
+					<button class="btn btn-default" type="button" id="cart-add-billing-address">
+						<span class="icon icon-plus"></span> New Billing Address</button>
+				</div>
+			</div>
+			<hr>
+		</div>
+		<p class="pull-right"><button class="btn btn-success btn-place-order" type="button">Place Order</button></p>
+	</div>
+</div>
+{% endblock %}
\ No newline at end of file
diff --git a/erpnext/templates/pages/cart.py b/erpnext/templates/pages/cart.py
new file mode 100644
index 0000000..ee55e5c
--- /dev/null
+++ b/erpnext/templates/pages/cart.py
@@ -0,0 +1,7 @@
+# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
+# License: GNU General Public License v3. See license.txt
+
+from __future__ import unicode_literals
+
+no_cache = True
+no_sitemap = True
\ No newline at end of file
diff --git a/erpnext/templates/pages/invoice.html b/erpnext/templates/pages/invoice.html
new file mode 100644
index 0000000..45867ea
--- /dev/null
+++ b/erpnext/templates/pages/invoice.html
@@ -0,0 +1,5 @@
+{% extends "templates/sale.html" %}
+
+{% block status -%}
+	{% if doc.status %}{{ doc.status }}{% endif %}
+{%- endblock %}
\ No newline at end of file
diff --git a/erpnext/templates/pages/invoice.py b/erpnext/templates/pages/invoice.py
new file mode 100644
index 0000000..9d6a558
--- /dev/null
+++ b/erpnext/templates/pages/invoice.py
@@ -0,0 +1,30 @@
+# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
+# License: GNU General Public License v3. See license.txt
+
+from __future__ import unicode_literals
+import webnotes
+from webnotes import _
+from webnotes.utils import flt, fmt_money
+
+no_cache = True
+
+def get_context():
+	from erpnext.templates.utils import get_transaction_context
+	context = get_transaction_context("Sales Invoice", webnotes.form_dict.name)
+	modify_status(context.get("doc"))
+	context.update({
+		"parent_link": "invoices",
+		"parent_title": "Invoices"
+	})
+	return context
+	
+def modify_status(doc):
+	doc.status = ""
+	if flt(doc.outstanding_amount):
+		doc.status = '<span class="label %s"><i class="icon-fixed-width %s"></i> %s</span>' % \
+			("label-warning", "icon-exclamation-sign", 
+			_("To Pay") + " = " + fmt_money(doc.outstanding_amount, currency=doc.currency))
+	else:
+		doc.status = '<span class="label %s"><i class="icon-fixed-width %s"></i> %s</span>' % \
+			("label-success", "icon-ok", _("Paid"))
+		
\ No newline at end of file
diff --git a/erpnext/templates/pages/invoices.html b/erpnext/templates/pages/invoices.html
new file mode 100644
index 0000000..0467f34
--- /dev/null
+++ b/erpnext/templates/pages/invoices.html
@@ -0,0 +1 @@
+{% extends "templates/sales_transactions.html" %}
\ No newline at end of file
diff --git a/erpnext/templates/pages/invoices.py b/erpnext/templates/pages/invoices.py
new file mode 100644
index 0000000..448c525
--- /dev/null
+++ b/erpnext/templates/pages/invoices.py
@@ -0,0 +1,28 @@
+# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
+# License: GNU General Public License v3. See license.txt
+
+from __future__ import unicode_literals
+import webnotes
+
+no_cache = True
+
+def get_context():
+	from erpnext.templates.utils import get_currency_context
+	context = get_currency_context()
+	context.update({
+		"title": "Invoices",
+		"method": "accounts.doctype.sales_invoice.templates.pages.invoices.get_invoices",
+		"icon": "icon-file-text",
+		"empty_list_message": "No Invoices Found",
+		"page": "invoice"
+	})
+	return context
+	
+@webnotes.whitelist()
+def get_invoices(start=0):
+	from erpnext.templates.utils import get_transaction_list
+	from erpnext.accounts.doctype.sales_invoice.templates.pages.invoice import modify_status
+	invoices = get_transaction_list("Sales Invoice", start, ["outstanding_amount"])
+	for d in invoices:
+		modify_status(d)
+	return invoices
\ No newline at end of file
diff --git a/erpnext/templates/pages/product_search.html b/erpnext/templates/pages/product_search.html
new file mode 100644
index 0000000..02c161c
--- /dev/null
+++ b/erpnext/templates/pages/product_search.html
@@ -0,0 +1,33 @@
+{% extends base_template %}
+
+{% set title="Product Search" %}
+
+{% block javascript %}
+<script>{% include "stock/doctype/item/templates/includes/product_list.js" %}</script>
+{% endblock %}
+
+{% block content %}
+<script>
+$(document).ready(function() {
+	var txt = get_url_arg("q");
+	$(".search-results").html("Search results for: " + txt);
+	window.search = txt;
+	window.start = 0;
+	window.get_product_list();
+});
+</script>
+
+{% include "stock/doctype/item/templates/includes/product_search_box.html" %}
+<div class="container content">
+	<h3 class="search-results">Search Results</h3>
+	<div id="search-list" class="row">
+		
+	</div>
+	<div style="text-align: center;">
+		<div class="more-btn" 
+			style="display: none; text-align: center;">
+			<button class="btn">More...</button>
+		</div>
+	</div>
+</div>
+{% endblock %}
\ No newline at end of file
diff --git a/erpnext/templates/pages/product_search.py b/erpnext/templates/pages/product_search.py
new file mode 100644
index 0000000..41f6b56
--- /dev/null
+++ b/erpnext/templates/pages/product_search.py
@@ -0,0 +1,6 @@
+# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
+# License: GNU General Public License v3. See license.txt
+
+from __future__ import unicode_literals
+
+no_cache = True
\ No newline at end of file
diff --git a/erpnext/templates/pages/profile.html b/erpnext/templates/pages/profile.html
new file mode 100644
index 0000000..880b8d4
--- /dev/null
+++ b/erpnext/templates/pages/profile.html
@@ -0,0 +1,55 @@
+{% extends base_template %}
+
+{% set title="My Profile" %}
+
+{% block content %}
+<div class="container content">
+    <ul class="breadcrumb">
+    	<li><a href="index">Home</a></li>
+    	<li class="active"><i class="icon-user icon-fixed-width"></i> My Profile</li>
+    </ul>
+	<div class="alert alert-warning" id="message" style="display: none;"></div>
+	<form>
+		<fieldset>
+			<label>Full Name</label>
+			<input class="form-control" type="text" id="fullname" placeholder="Your Name">
+		</fieldset>
+		<fieldset>
+			<label>Company Name</label>
+			<input class="form-control" type="text" id="company_name" placeholder="Company Name" value="{{ company_name }}">
+		</fieldset>
+		<fieldset>
+			<label>Mobile No</label>
+			<input class="form-control" type="text" id="mobile_no" placeholder="Mobile No" value="{{ mobile_no }}">
+		</fieldset>
+		<fieldset>
+			<label>Phone</label>
+			<input class="form-control" type="text" id="phone" placeholder="Phone" value="{{ phone }}">
+		</fieldset>
+		<button id="update_profile" type="submit" class="btn btn-default">Update</button>
+	</form>
+</div>
+<script>
+$(document).ready(function() {
+	$("#fullname").val(getCookie("full_name") || "");
+	$("#update_profile").click(function() {
+		wn.call({
+			method: "erpnext.templates.pages.profile.update_profile",
+			type: "POST",
+			args: {
+				fullname: $("#fullname").val(),
+				company_name: $("#company_name").val(),
+				mobile_no: $("#mobile_no").val(),
+				phone: $("#phone").val()
+			},
+			btn: this,
+			msg: $("#message"),
+			callback: function(r) {
+				if(!r.exc) $("#user-full-name").html($("#fullname").val());
+			}
+		});
+		return false;
+	})
+})
+</script>
+{% endblock %}
\ No newline at end of file
diff --git a/erpnext/templates/pages/profile.py b/erpnext/templates/pages/profile.py
new file mode 100644
index 0000000..143abef
--- /dev/null
+++ b/erpnext/templates/pages/profile.py
@@ -0,0 +1,40 @@
+# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
+# License: GNU General Public License v3. See license.txt
+
+from __future__ import unicode_literals
+import webnotes
+from webnotes import _
+from webnotes.utils import cstr
+
+no_cache = True
+no_sitemap = True
+
+def get_context():
+	from erpnext.selling.utils.cart import get_lead_or_customer
+	party = get_lead_or_customer()
+	if party.doctype == "Lead":
+		mobile_no = party.mobile_no
+		phone = party.phone
+	else:
+		mobile_no, phone = webnotes.conn.get_value("Contact", {"email_id": webnotes.session.user, 
+			"customer": party.name}, ["mobile_no", "phone"])
+		
+	return {
+		"company_name": cstr(party.customer_name if party.doctype == "Customer" else party.company_name),
+		"mobile_no": cstr(mobile_no),
+		"phone": cstr(phone)
+	}
+	
+@webnotes.whitelist()
+def update_profile(fullname, password=None, company_name=None, mobile_no=None, phone=None):
+	from erpnext.selling.utils.cart import update_party
+	update_party(fullname, company_name, mobile_no, phone)
+	
+	if not fullname:
+		return _("Name is required")
+		
+	webnotes.conn.set_value("Profile", webnotes.session.user, "first_name", fullname)
+	webnotes._response.set_cookie("full_name", fullname)
+	
+	return _("Updated")
+	
\ No newline at end of file
diff --git a/erpnext/templates/pages/shipment.html b/erpnext/templates/pages/shipment.html
new file mode 100644
index 0000000..d0aaa3e
--- /dev/null
+++ b/erpnext/templates/pages/shipment.html
@@ -0,0 +1 @@
+{% extends "templates/sale.html" %}
\ No newline at end of file
diff --git a/erpnext/templates/pages/shipment.py b/erpnext/templates/pages/shipment.py
new file mode 100644
index 0000000..e744685
--- /dev/null
+++ b/erpnext/templates/pages/shipment.py
@@ -0,0 +1,16 @@
+# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
+# License: GNU General Public License v3. See license.txt
+
+from __future__ import unicode_literals
+import webnotes
+
+no_cache = True
+
+def get_context():
+	from erpnext.templates.utils import get_transaction_context
+	context = get_transaction_context("Delivery Note", webnotes.form_dict.name)
+	context.update({
+		"parent_link": "shipments",
+		"parent_title": "Shipments"
+	})
+	return context
\ No newline at end of file
diff --git a/erpnext/templates/pages/shipments.html b/erpnext/templates/pages/shipments.html
new file mode 100644
index 0000000..0467f34
--- /dev/null
+++ b/erpnext/templates/pages/shipments.html
@@ -0,0 +1 @@
+{% extends "templates/sales_transactions.html" %}
\ No newline at end of file
diff --git a/erpnext/templates/pages/shipments.py b/erpnext/templates/pages/shipments.py
new file mode 100644
index 0000000..03d074a
--- /dev/null
+++ b/erpnext/templates/pages/shipments.py
@@ -0,0 +1,24 @@
+# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
+# License: GNU General Public License v3. See license.txt
+
+from __future__ import unicode_literals
+import webnotes
+
+no_cache = True
+
+def get_context():
+	from erpnext.templates.utils import get_currency_context
+	context = get_currency_context()
+	context.update({
+		"title": "Shipments",
+		"method": "erpnext.templates.pages.shipments.get_shipments",
+		"icon": "icon-truck",
+		"empty_list_message": "No Shipments Found",
+		"page": "shipment"
+	})
+	return context
+	
+@webnotes.whitelist()
+def get_shipments(start=0):
+	from erpnext.templates.utils import get_transaction_list
+	return get_transaction_list("Delivery Note", start)
diff --git a/erpnext/templates/pages/ticket.html b/erpnext/templates/pages/ticket.html
new file mode 100644
index 0000000..1732e77
--- /dev/null
+++ b/erpnext/templates/pages/ticket.html
@@ -0,0 +1,121 @@
+{% extends base_template %}
+
+{% set title=doc.name %}
+
+{% set status_label = {
+	"Open": "label-success",
+	"To Reply": "label-danger",
+	"Closed": "label-default"
+} %}
+
+{% block content %}
+<div class="container content">
+    <ul class="breadcrumb">
+    	<li><a href="index">Home</a></li>
+    	<li><a href="tickets">My Tickets</a></li>
+    	<li class="active"><i class="icon-ticket icon-fixed-width"></i> {{ doc.name }}</li>
+    </ul>
+	<h3><i class="icon-ticket icon-fixed-width"></i> {{ doc.name }}</h3>
+	{% if doc.name == "Not Allowed" -%}
+		<script>ask_to_login();</script>
+	{% else %}
+	<hr>
+	{%- if doc.status -%}
+	{% if doc.status == "Waiting for Customer" -%}
+		{% set status = "To Reply" %}
+	{% else %}
+		{% set status = doc.status %}
+	{%- endif -%}
+	<div class="row">
+		<div class="col-md-2" style="margin-bottom: 7px;">
+			<span class="label {{ status_label.get(status) or 'label-default' }}">{{ status }}</span>
+		</div>
+		<div class="col-md-8">
+			<div class="row col-md-12">{{ doc.subject }}</div>
+		</div>
+		<div class="col-md-2">
+			<span class="text-muted pull-right">{{ utils.formatdate(doc.creation) }}</span>
+		</div>
+	</div>
+	<div class="row">
+		<h4 class="col-xs-6">Messages</h4>
+		<div class="col-xs-6">
+			 <button class="btn btn-sm btn-primary pull-right" id="ticket-reply">
+				  <i class="icon-envelope icon-fixed-width"></i> Reply</button>
+			 <button class="btn btn-sm btn-success pull-right hide" id="ticket-reply-send">
+				  <i class="icon-arrow-right icon-fixed-width"></i> Send</button>
+		</div>
+	</div>
+	<p id="ticket-alert" class="alert alert-danger" 
+		style="display: none;">&nbsp;</p>
+	{%- if doclist.get({"doctype":"Communication"}) -%}
+	<div>
+		<table class="table table-bordered table-striped" id="ticket-thread">
+			<tbody>
+				{%- for comm in 
+					(doclist.get({"doctype":"Communication"})|sort(reverse=True, attribute="creation")) %}
+				<tr>
+					<td>
+					<h5 style="text-transform: none">
+						{{ comm.sender }} on {{ utils.formatdate(comm.creation) }}</h5>
+					<hr>
+					<p>{{ webnotes.utils.is_html(comm.content) and comm.content or
+						comm.content.replace("\n", "<br>")}}</p>
+					</td>
+				</tr>
+				{% endfor -%}
+			</tbody>
+		</table>
+	</div>
+	{%- else -%}
+	<div class="alert">No messages</div>
+	{%- endif -%}
+	{%- endif -%}
+	{% endif -%}
+</div>
+{% endblock %}
+
+{% block javascript %}
+<script>
+$(document).ready(function() {
+	$("#ticket-reply").on("click", function() {
+		if(!$("#ticket-reply-editor").length) {
+			$('<tr id="ticket-reply-editor"><td>\
+				<h5 style="text-transform: none">Reply</h5>\
+				<hr>\
+				<textarea rows=10 class="form-control" style="resize: vertical;"></textarea>\
+			</td></tr>').prependTo($("#ticket-thread").find("tbody"));
+			$("#ticket-reply").addClass("hide");
+			$("#ticket-reply-send").removeClass("hide");
+		}
+	});
+	
+	$("#ticket-reply-send").on("click", function() {
+		var reply = $("#ticket-reply-editor").find("textarea").val().trim();
+		if(!reply) {
+			msgprint("Please write something in reply!");
+		} else {
+			wn.call({
+				type: "POST",
+				method: "support.doctype.support_ticket.templates.pages.ticket.add_reply",
+				btn: this,
+				args: { ticket: "{{ doc.name }}", message: reply },
+				callback: function(r) {
+					if(r.exc) {
+						msgprint(r._server_messages 
+							? JSON.parse(r._server_messages).join("<br>")
+							: "Something went wrong!");
+					} else {
+						window.location.reload();
+					}
+				}
+			})
+		}
+	});
+});
+
+var msgprint = function(txt) {
+	if(txt) $("#ticket-alert").html(txt).toggle(true);
+}
+</script>
+{% endblock %}
\ No newline at end of file
diff --git a/erpnext/templates/pages/ticket.py b/erpnext/templates/pages/ticket.py
new file mode 100644
index 0000000..f9e5c88
--- /dev/null
+++ b/erpnext/templates/pages/ticket.py
@@ -0,0 +1,37 @@
+# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
+# License: GNU General Public License v3. See license.txt
+
+from __future__ import unicode_literals
+import webnotes
+from webnotes import _
+from webnotes.utils import today
+
+no_cache = True
+
+def get_context():
+	bean = webnotes.bean("Support Ticket", webnotes.form_dict.name)
+	if bean.doc.raised_by != webnotes.session.user:
+		return {
+			"doc": {"name": "Not Allowed"}
+		}
+	else:
+		return {
+			"doc": bean.doc,
+			"doclist": bean.doclist,
+			"webnotes": webnotes,
+			"utils": webnotes.utils
+		}
+
+@webnotes.whitelist()
+def add_reply(ticket, message):
+	if not message:
+		raise webnotes.throw(_("Please write something"))
+	
+	bean = webnotes.bean("Support Ticket", ticket)
+	if bean.doc.raised_by != webnotes.session.user:
+		raise webnotes.throw(_("You are not allowed to reply to this ticket."), webnotes.PermissionError)
+	
+	from webnotes.core.doctype.communication.communication import make
+	make(content=message, sender=bean.doc.raised_by, subject = bean.doc.subject,
+		doctype="Support Ticket", name=bean.doc.name,
+		date=today())
\ No newline at end of file
diff --git a/erpnext/templates/pages/tickets.html b/erpnext/templates/pages/tickets.html
new file mode 100644
index 0000000..6942d3b
--- /dev/null
+++ b/erpnext/templates/pages/tickets.html
@@ -0,0 +1,87 @@
+{% extends "templates/includes/transactions.html" %}
+
+{% block javascript -%}
+{{ super() }}
+
+<script>
+	var status_label = {
+		"Open": "label-success",
+		"Waiting for Customer": "label-danger",
+		"Closed": "label-default"
+	}
+
+	var render = function(doc) {
+		doc.status = doc.status.trim();
+		doc.label_class = status_label[doc.status] || "label-default";
+		if(doc.status==="Waiting for Customer") doc.status = "To Reply";
+	
+		$(repl('<a href="{{ page }}?name=%(name)s" class="list-group-item">\
+				<div class="row">\
+					<div class="col-md-2" style="margin-bottom: 7px;"><span class="label %(label_class)s">\
+						%(status)s</span></div>\
+					<div class="col-md-8">\
+						<div class="row col-md-12">%(name)s</div>\
+						<div class="row col-md-12 text-muted">%(subject)s</div>\
+					</div>\
+					<div class="col-md-2 pull-right">\
+						<span class="text-muted">%(creation)s</span>\
+					</div>\
+				</div>\
+			</a>', doc)).appendTo($list);
+	};
+	
+	$(document).ready(function() {
+		if(!window.$new_ticket) {
+			window.$new_ticket = $('<div>\
+					<button class="btn btn-primary" style="margin-bottom: 15px;" id="new-ticket">\
+						<i class="icon-tag icon-fixed-width"></i> New Ticket\
+					</button>\
+					<button class="btn btn-success hide" style="margin-bottom: 15px;" id="new-ticket-send">\
+						<i class="icon-arrow-right icon-fixed-width"></i> Send\
+					</button>\
+				</div>').insertBefore(".transaction-list");
+		}
+		
+		window.$new_ticket.find("#new-ticket").on("click", function() {
+			$(this).addClass("hide");
+			$(window.$new_ticket).find("#new-ticket-send").removeClass("hide");
+			$('<div class="well" id="ticket-editor">\
+					<div class="form-group"><input class="form-control" type="data"\
+						 placeholder="Subject" data-fieldname="subject"></div>\
+					<div class="form-group"><textarea rows=10 class="form-control" \
+						 style="resize: vertical;" placeholder="Message" \
+						 data-fieldname="message"></textarea></div>\
+				</div>')
+				.insertAfter(window.$new_ticket);
+		});
+		
+		window.$new_ticket.find("#new-ticket-send").on("click", function() {
+			var subject = $("#ticket-editor").find('[data-fieldname="subject"]').val().trim();
+			var message = $("#ticket-editor").find('[data-fieldname="message"]').val().trim();
+			if(!(subject && message)) {
+				msgprint("Please write something in subject and message!");
+			} else {
+				wn.call({
+					type: "POST",
+					method: "support.doctype.support_ticket.templates.pages.tickets.make_new_ticket",
+					btn: this,
+					args: { subject: subject, message: message },
+					callback: function(r) {
+						if(r.exc) {
+							msgprint(r._server_messages 
+								? JSON.parse(r._server_messages).join("<br>")
+								: "Something went wrong!");
+						} else {
+							window.location.href = "ticket?name=" + encodeURIComponent(r.message);
+						}
+					}
+				})
+			}
+		});
+	});
+	
+	var msgprint = function(txt) {
+		if(txt) $("#msgprint-alert").html(txt).toggle(true);
+	}
+</script>
+{%- endblock %}
\ No newline at end of file
diff --git a/erpnext/templates/pages/tickets.py b/erpnext/templates/pages/tickets.py
new file mode 100644
index 0000000..7434af2
--- /dev/null
+++ b/erpnext/templates/pages/tickets.py
@@ -0,0 +1,38 @@
+# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
+# License: GNU General Public License v3. See license.txt
+
+from __future__ import unicode_literals
+import webnotes
+from webnotes.utils import cint, formatdate
+
+no_cache = True
+
+def get_context():
+	return {
+		"title": "My Tickets",
+		"method": "support.doctype.support_ticket.templates.pages.tickets.get_tickets",
+		"icon": "icon-ticket",
+		"empty_list_message": "No Tickets Raised",
+		"page": "ticket"
+	}
+
+@webnotes.whitelist()
+def get_tickets(start=0):
+	tickets = webnotes.conn.sql("""select name, subject, status, creation 
+		from `tabSupport Ticket` where raised_by=%s 
+		order by modified desc
+		limit %s, 20""", (webnotes.session.user, cint(start)), as_dict=True)
+	for t in tickets:
+		t.creation = formatdate(t.creation)
+	
+	return tickets
+	
+@webnotes.whitelist()
+def make_new_ticket(subject, message):
+	if not (subject and message):
+		raise webnotes.throw(_("Please write something in subject and message!"))
+		
+	from erpnext.support.doctype.support_ticket.get_support_mails import add_support_communication
+	ticket = add_support_communication(subject, message, webnotes.session.user)
+	
+	return ticket.doc.name
\ No newline at end of file