[website] [minor] moving to framework
diff --git a/portal/templates/__init__.py b/portal/templates/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/portal/templates/__init__.py
diff --git a/portal/templates/base.html b/portal/templates/base.html
index 701d86c..cdbc045 100644
--- a/portal/templates/base.html
+++ b/portal/templates/base.html
@@ -1,20 +1,22 @@
 {% extends "lib/website/templates/base.html" %}
 
 {% block toolbar %}
-<div class="pull-right" style="margin:4px;" id="user-tools">
-	{% if shopping_cart_enabled -%}
-	<a href="cart" title="Shopping Cart"><i class="icon-shopping-cart"></i> 
-		<span class="cart-count"></span></a> |
-	{%- endif %}
-	<a id="login-link" href="login">Login</a>
-</div>
-<div class="pull-right hide" style="margin:4px;" id="user-tools-post-login">
-	<a href="account" title="My Account" id="user-full-name"></a> |
-	{% if shopping_cart_enabled -%}
-	<a href="cart" title="Shopping Cart"><i class="icon-shopping-cart"></i> 
-		<span class="cart-count"></span></a> |
-	{%- endif %}
-	<a href="server.py?cmd=web_logout" title="Sign Out"><i class="icon-signout"></i></a>
+<div class="row">
+	<div class="pull-right" style="margin:4px;" id="user-tools">
+		{% if shopping_cart_enabled -%}
+		<a href="cart" title="Shopping Cart"><i class="icon-shopping-cart"></i> 
+			<span class="cart-count"></span></a> |
+		{%- endif %}
+		<a id="login-link" href="login">Login</a>
+	</div>
+	<div class="pull-right hide" style="margin:4px;" id="user-tools-post-login">
+		<a href="account" title="My Account" id="user-full-name"></a> |
+		{% if shopping_cart_enabled -%}
+		<a href="cart" title="Shopping Cart"><i class="icon-shopping-cart"></i> 
+			<span class="cart-count"></span></a> |
+		{%- endif %}
+		<a href="server.py?cmd=web_logout" title="Sign Out"><i class="icon-signout"></i></a>
+	</div>
 </div>
 {% endblock %}
 
diff --git a/portal/templates/includes/transactions.html b/portal/templates/includes/transactions.html
index 1e61124..23d5f81 100644
--- a/portal/templates/includes/transactions.html
+++ b/portal/templates/includes/transactions.html
@@ -1,4 +1,4 @@
-{% extends "app/website/templates/html/page.html" %}
+{% extends base_template %}
 
 {% block content -%}
 <div class="col-md-12">
@@ -19,6 +19,7 @@
 {%- endblock %}
 
 {% block javascript -%}
+<script>
 $(document).ready(function() {
 	window.start = 0;
 	window.$list = $(".transaction-list");
@@ -53,7 +54,7 @@
 		}
 	})
 };
+</script>
 
-// var render = function(doc) { };
-
+<!-- // var render = function(doc) { }; -->
 {% endblock %}
\ No newline at end of file
diff --git a/portal/templates/invoice.html b/portal/templates/invoice.html
deleted file mode 100644
index 26ddea4..0000000
--- a/portal/templates/invoice.html
+++ /dev/null
@@ -1,88 +0,0 @@
-{% extends "app/website/templates/html/page.html" %}
-
-{% set title=doc.name %}
-
-{% block content %}
-<div class="col-md-12">
-    <ul class="breadcrumb">
-    	<li><a href="index">Home</a></li>
-    	<li><a href="account">My Account</a></li>
-    	<li><a href="invoices">Invoices</a></li>
-    	<li class="active"><i class="icon-file-text icon-fixed-width"></i> {{ doc.name }}</li>
-    </ul>
-	<h3><i class="icon-file icon-fixed-width"></i> {{ doc.name }}</h3>
-	<hr>
-	{%- if doc.status -%}
-	<div style="font-size: 13px;">
-	<div class="row">
-		<div class="col-md-2">
-			<div class="label">{{ doc.status }}</div>
-		</div>
-		<div class="col-md-4">
-			{{ utils.formatdate(doc.transaction_date) }}
-		</div>
-	</div>
-	<br>
-	<div class="row">
-		<div class="col-md-12">
-		<table class="table table-bordered">
-			<tbody>
-				<tr>
-					<th>Sr</th>
-					<th>Item Name</th>
-					<th>Description</th>
-					<th>Qty</th>
-					<th>UoM</th>
-					<th>Basic Rate</th>
-					<th>Amount</th>
-				</tr>
-				{%- for row in doclist.get({"doctype":"Sales Order Item"}) %}
-				<tr>
-					<td style="width: 3%;">{{ row.idx }}</td>
-					<td style="width: 20%;">{{ row.item_name }}</td>
-					<td style="width: 37%;">{{ row.description }}</td>
-					<td style="width: 5%; text-align: right;">{{ row.qty }}</td>
-					<td style="width: 5%;">{{ row.stock_uom }}</td>
-					<td style="width: 15%; text-align: right;">{{ utils.fmt_money(row.export_rate, currency=doc.currency) }}</td>
-					<td style="width: 15%; text-align: right;">{{ utils.fmt_money(row.export_amount, currency=doc.currency) }}</td>
-				</tr>
-				{% endfor -%}
-			</tbody>
-		</table>
-		</div>
-	</div>
-	<div class="row">
-		<div class="col-md-6"></div>
-		<div class="col-md-6">
-		<table cellspacing=0 width=100%>
-		<tbody>
-			<tr>
-				<td>Net Total</td>
-				<td width=40% style="text-align: right;">{{
-					utils.fmt_money(doc.net_total/doc.conversion_rate, currency=doc.currency)
-				}}</td>
-			</tr>
-			{%- for charge in doclist.get({"doctype":"Sales Taxes and Charges"}) -%}
-			{%- if not charge.included_in_print_rate -%}
-			<tr>
-				<td>{{ charge.description }}</td>
-				<td style="text-align: right;">{{ utils.fmt_money(charge.tax_amount / doc.conversion_rate, currency=doc.currency) }}</td>
-			</tr>
-			{%- endif -%}
-			{%- endfor -%}
-			<tr>
-				<td>Grand Total</td>
-				<td style="text-align: right;">{{ utils.fmt_money(doc.grand_total_export, currency=doc.currency) }}</td>
-			</tr>
-			<tr style='font-weight: bold'>
-				<td>Rounded Total</td>
-				<td style="text-align: right;">{{ utils.fmt_money(doc.rounded_total_export, currency=doc.currency) }}</td>
-			</tr>
-		</tbody>
-		</table>	
-		</div>
-	</div>
-	</div>
-	{%- endif -%}
-</div>
-{% endblock %}
\ No newline at end of file
diff --git a/portal/templates/pages/__init__.py b/portal/templates/pages/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/portal/templates/pages/__init__.py
diff --git a/portal/templates/account.html b/portal/templates/pages/account.html
similarity index 94%
rename from portal/templates/account.html
rename to portal/templates/pages/account.html
index 2a5acf6..da43dd2 100644
--- a/portal/templates/account.html
+++ b/portal/templates/pages/account.html
@@ -1,4 +1,4 @@
-{% extends "app/website/templates/html/page.html" %}
+{% extends base_template %}
 
 {% set title="My Account" %}
 
diff --git a/portal/templates/cart.html b/portal/templates/pages/cart.html
similarity index 96%
rename from portal/templates/cart.html
rename to portal/templates/pages/cart.html
index 6708ad3..372f524 100644
--- a/portal/templates/cart.html
+++ b/portal/templates/pages/cart.html
@@ -1,4 +1,4 @@
-{% extends "app/website/templates/html/page.html" %}
+{% extends base_template %}
 
 {% block javascript %}
 	{% include "app/website/templates/js/cart.js" %}
diff --git a/portal/templates/pages/invoice.html b/portal/templates/pages/invoice.html
new file mode 100644
index 0000000..376e5df
--- /dev/null
+++ b/portal/templates/pages/invoice.html
@@ -0,0 +1 @@
+{% extends "app/portal/templates/sale.html" %}
\ No newline at end of file
diff --git a/portal/templates/pages/invoice.py b/portal/templates/pages/invoice.py
new file mode 100644
index 0000000..ed6e40a
--- /dev/null
+++ b/portal/templates/pages/invoice.py
@@ -0,0 +1,14 @@
+# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd.
+# License: GNU General Public License v3. See license.txt
+
+from __future__ import unicode_literals
+import webnotes
+
+def get_context():
+	from portal.website_transactions import get_transaction_context
+	context = get_transaction_context("Sales Invoice", webnotes.form_dict.name)
+	context.update({
+		"parent_link": "invoices",
+		"parent_title": "Invoices"
+	})
+	return context
\ No newline at end of file
diff --git a/portal/templates/pages/invoices.html b/portal/templates/pages/invoices.html
new file mode 100644
index 0000000..f108683
--- /dev/null
+++ b/portal/templates/pages/invoices.html
@@ -0,0 +1 @@
+{% extends "app/portal/templates/sales_transactions.html" %}
\ No newline at end of file
diff --git a/portal/templates/pages/invoices.py b/portal/templates/pages/invoices.py
new file mode 100644
index 0000000..2bb6490
--- /dev/null
+++ b/portal/templates/pages/invoices.py
@@ -0,0 +1,22 @@
+# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd.
+# License: GNU General Public License v3. See license.txt
+
+from __future__ import unicode_literals
+import webnotes
+
+def get_context():
+	from portal.website_transactions import get_currency_context
+	context = get_currency_context()
+	context.update({
+		"title": "Invoices",
+		"method": "portal.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 portal.website_transactions import get_transaction_list
+	return get_transaction_list("Sales Invoice", start)
\ No newline at end of file
diff --git a/portal/templates/pages/order.html b/portal/templates/pages/order.html
new file mode 100644
index 0000000..376e5df
--- /dev/null
+++ b/portal/templates/pages/order.html
@@ -0,0 +1 @@
+{% extends "app/portal/templates/sale.html" %}
\ No newline at end of file
diff --git a/portal/templates/pages/order.py b/portal/templates/pages/order.py
new file mode 100644
index 0000000..47e2c68
--- /dev/null
+++ b/portal/templates/pages/order.py
@@ -0,0 +1,14 @@
+# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd.
+# License: GNU General Public License v3. See license.txt
+
+from __future__ import unicode_literals
+import webnotes
+
+def get_context():
+	from portal.website_transactions import get_transaction_context
+	context = get_transaction_context("Sales Order", webnotes.form_dict.name)
+	context.update({
+		"parent_link": "orders",
+		"parent_title": "My Orders"
+	})
+	return context
\ No newline at end of file
diff --git a/portal/templates/pages/orders.html b/portal/templates/pages/orders.html
new file mode 100644
index 0000000..f108683
--- /dev/null
+++ b/portal/templates/pages/orders.html
@@ -0,0 +1 @@
+{% extends "app/portal/templates/sales_transactions.html" %}
\ No newline at end of file
diff --git a/portal/templates/pages/orders.py b/portal/templates/pages/orders.py
new file mode 100644
index 0000000..3c62d35
--- /dev/null
+++ b/portal/templates/pages/orders.py
@@ -0,0 +1,23 @@
+# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd.
+# License: GNU General Public License v3. See license.txt
+
+from __future__ import unicode_literals
+import webnotes
+
+def get_context():
+	from portal.website_transactions import get_currency_context
+	context = get_currency_context()
+	context.update({
+		"title": "My Orders",
+		"method": "portal.templates.pages.orders.get_orders",
+		"icon": "icon-list",
+		"empty_list_message": "No Orders Yet",
+		"page": "order",
+	})
+	return context
+	
+@webnotes.whitelist()
+def get_orders(start=0):
+	from portal.website_transactions import get_transaction_list
+	return get_transaction_list("Sales Order", start)
+	
\ No newline at end of file
diff --git a/portal/templates/pages/profile.html b/portal/templates/pages/profile.html
new file mode 100644
index 0000000..2fe03ba
--- /dev/null
+++ b/portal/templates/pages/profile.html
@@ -0,0 +1,61 @@
+{% extends base_template %}
+
+{% set title="My Profile" %}
+
+{% block content %}
+<div class="col-md-12">
+    <ul class="breadcrumb">
+    	<li><a href="index">Home</a></li>
+    	<li><a href="account">My Account</a></li>
+    	<li class="active"><i class="icon-user icon-fixed-width"></i> My Profile</li>
+    </ul>
+	<div class="alert" 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>Password</label>
+			<input class="form-control" type="password" id="password" placeholder="Password">
+		</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: "startup.webutils.update_profile",
+			type: "POST",
+			args: {
+				fullname: $("#fullname").val(),
+				password: $("#password").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/portal/templates/pages/shipment.html b/portal/templates/pages/shipment.html
new file mode 100644
index 0000000..376e5df
--- /dev/null
+++ b/portal/templates/pages/shipment.html
@@ -0,0 +1 @@
+{% extends "app/portal/templates/sale.html" %}
\ No newline at end of file
diff --git a/portal/templates/pages/shipment.py b/portal/templates/pages/shipment.py
new file mode 100644
index 0000000..5d9d1d1
--- /dev/null
+++ b/portal/templates/pages/shipment.py
@@ -0,0 +1,14 @@
+# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd.
+# License: GNU General Public License v3. See license.txt
+
+from __future__ import unicode_literals
+import webnotes
+
+def get_context():
+	from portal.website_transactions 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/portal/templates/pages/shipments.html b/portal/templates/pages/shipments.html
new file mode 100644
index 0000000..f108683
--- /dev/null
+++ b/portal/templates/pages/shipments.html
@@ -0,0 +1 @@
+{% extends "app/portal/templates/sales_transactions.html" %}
\ No newline at end of file
diff --git a/portal/templates/pages/shipments.py b/portal/templates/pages/shipments.py
new file mode 100644
index 0000000..4847b9f
--- /dev/null
+++ b/portal/templates/pages/shipments.py
@@ -0,0 +1,22 @@
+# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd.
+# License: GNU General Public License v3. See license.txt
+
+from __future__ import unicode_literals
+import webnotes
+
+def get_context():
+	from portal.website_transactions import get_currency_context
+	context = get_currency_context()
+	context.update({
+		"title": "Shipments",
+		"method": "portal.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 portal.website_transactions import get_transaction_list
+	return get_transaction_list("Delivery Note", start)
diff --git a/portal/templates/profile.html b/portal/templates/profile.html
index 4c03b40..e8e60b4 100644
--- a/portal/templates/profile.html
+++ b/portal/templates/profile.html
@@ -1,4 +1,4 @@
-{% extends "app/website/templates/html/page.html" %}
+{% extends base_template %}
 
 {% set title="My Profile" %}
 
@@ -9,7 +9,7 @@
     	<li><a href="account">My Account</a></li>
     	<li class="active"><i class="icon-user icon-fixed-width"></i> My Profile</li>
     </ul>
-	<div class="alert" id="message" style="display: none;"></div>
+	<div class="alert alert-warning" id="message" style="display: none;"></div>
 	<form>
 		<fieldset>
 			<label>Full Name</label>
diff --git a/portal/templates/sale.html b/portal/templates/sale.html
index 1c03da2..3a49684 100644
--- a/portal/templates/sale.html
+++ b/portal/templates/sale.html
@@ -1,4 +1,4 @@
-{% extends "app/website/templates/html/page.html" %}
+{% extends base_template %}
 
 {% set title=doc.name %}
 
diff --git a/portal/templates/sales_transactions.html b/portal/templates/sales_transactions.html
index 7215339..10139c3 100644
--- a/portal/templates/sales_transactions.html
+++ b/portal/templates/sales_transactions.html
@@ -1,25 +1,28 @@
-{% extends "app/website/templates/html/transactions.html" %}
+{% extends "app/portal/templates/includes/transactions.html" %}
 
 {% block javascript -%}
-global_number_format = "{{ global_number_format }}";
-currency = "{{ currency }}";
-wn.currency_symbols = {{ currency_symbols }};
+<script>
+	global_number_format = "{{ global_number_format }}";
+	currency = "{{ currency }}";
+	wn.currency_symbols = {{ currency_symbols }};
+</script>
 
 {{ super() }}
 
-var render = function(doc) {
-	doc.grand_total_export = format_currency(doc.grand_total_export, doc.currency);
+<script>
+	var render = function(doc) {
+		doc.grand_total_export = format_currency(doc.grand_total_export, doc.currency);
 	
-	$(repl('<a href="{{ page }}?name=%(name)s" class="list-group-item">\
-			<div class="row">\
-				<div class="col-md-6">\
-					<div class="row col-md-12">%(name)s</div>\
-					<div class="row col-md-12 text-muted">%(items)s...</div>\
+		$(repl('<a href="{{ page }}?name=%(name)s" class="list-group-item">\
+				<div class="row">\
+					<div class="col-md-6">\
+						<div class="row col-md-12">%(name)s</div>\
+						<div class="row col-md-12 text-muted">%(items)s...</div>\
+					</div>\
+					<div class="col-md-3 text-right">%(grand_total_export)s</div>\
+					<div class="col-md-3 text-right text-muted">%(creation)s</div>\
 				</div>\
-				<div class="col-md-3 text-right">%(grand_total_export)s</div>\
-				<div class="col-md-3 text-right text-muted">%(creation)s</div>\
-			</div>\
-		</a>', doc)).appendTo($list);
-};
-
+			</a>', doc)).appendTo($list);
+	};
+</script>
 {%- endblock %}
\ No newline at end of file
diff --git a/portal/templates/transaction_list.html b/portal/templates/transaction_list.html
deleted file mode 100644
index 967a6a8..0000000
--- a/portal/templates/transaction_list.html
+++ /dev/null
@@ -1,77 +0,0 @@
-{% extends "app/website/templates/html/page.html" %}
-
-{% block content %}
-<div class="col-md-12">
-    <ul class="breadcrumb">
-    	<li><a href="index">Home</a></li>
-    	<li><a href="account">My Account</a></li>
-    	<li class="active"><i class="{{ icon }} icon-fixed-width"></i> {{ title }}</li>
-    </ul>
-	<div class="list-group transaction-list">
-		<div class="progress progress-striped active">
-			<div class="progress-bar progress-bar-info" style="width: 100%;"></div>
-		</div>
-	</div>
-	<div class="text-center">
-		<button class="btn btn-default btn-show-more" style="display: none;">More</button></div>
-</div>
-{% endblock %}
-
-{% block javascript %}
-global_number_format = "{{ global_number_format }}";
-currency = "{{ currency }}";
-wn.currency_symbols = {{ currency_symbols }};
-
-$(document).ready(function() {
-	var start = 0;
-	var $list = $(".transaction-list");
-	
-	var $show_more = $(".btn-show-more").on("click", function() {
-		get_transactions(this);
-	});
-	
-	var get_transactions = function(btn) {
-		wn.call({
-			method: "{{ method }}",
-			args: { start: start },
-			btn: btn,
-			callback: function(r) {
-				$list.find(".progress").remove();
-				$show_more.toggle(!(r.message && r.message.length===20));
-				
-				if(!(r.message && r.message.length)) {
-					console.log("empty");
-					if(!$list.html().trim()) {
-						$list.html("<div class='alert alert-warning'>\
-							{{ empty_list_message }}</div>");
-					}
-					return;
-				}
-			
-				start += r.message.length;
-			
-				$.each(r.message, function(i, doc) {
-					render(doc);
-				});
-			}
-		})
-	};
-	
-	var render = function(doc) {
-		doc.grand_total_export = format_currency(doc.grand_total_export, doc.currency);
-		
-		var $row = $(repl('<a href="{{ page }}?name=%(name)s" class="list-group-item">\
-				<div class="row">\
-					<div class="col-md-6">\
-						<div class="row col-md-12">%(name)s</div>\
-						<div class="row col-md-12 text-muted">%(items)s...</div>\
-					</div>\
-					<div class="col-md-3 text-right">%(grand_total_export)s</div>\
-					<div class="col-md-3 text-right text-muted">%(creation)s</div>\
-				</div>\
-			</a>', doc)).appendTo($list);
-	};
-	
-	get_transactions();
-});
-{% endblock %}
\ No newline at end of file