[minor] customer login start
diff --git a/website/helpers/transaction.py b/website/helpers/transaction.py
new file mode 100644
index 0000000..336be2a
--- /dev/null
+++ b/website/helpers/transaction.py
@@ -0,0 +1,63 @@
+# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd.
+# License: GNU General Public License v3. See license.txt
+
+from __future__ import unicode_literals
+import webnotes
+from webnotes.utils import cint, formatdate
+import json
+
+def get_transaction_list(doctype, start):
+ # find customer id
+ customer = webnotes.conn.get_value("Contact", {"email_id": webnotes.session.user},
+ "customer")
+
+ if customer:
+ transactions = webnotes.conn.sql("""select name, creation, currency, grand_total_export
+ from `tab%s` where customer=%s and docstatus=1
+ order by creation desc
+ limit %s, 20""" % (doctype, "%s", "%s"), (customer, cint(start)), as_dict=1)
+ for doc in transactions:
+ doc.items = ", ".join(webnotes.conn.sql_list("""select item_name
+ from `tab%s Item` where parent=%s limit 5""" % (doctype, "%s"), doc.name))
+ doc.creation = formatdate(doc.creation)
+ return transactions
+ else:
+ return []
+
+def get_common_args():
+ return {
+ "global_number_format": webnotes.conn.get_default("number_format") or "#,###.##",
+ "currency": webnotes.conn.get_default("currency"),
+ "currency_symbols": json.dumps(dict(webnotes.conn.sql("""select name, symbol
+ from tabCurrency where ifnull(enabled,0)=1""")))
+ }
+
+@webnotes.whitelist()
+def get_orders(start=0):
+ return get_transaction_list("Sales Order", start)
+
+def order_list_args():
+ args = get_common_args()
+ args.update({
+ "title": "My Orders",
+ "method": "website.helpers.transaction.get_orders",
+ "icon": "icon-list",
+ "empty_list_message": "No Orders Yet",
+ "page": "order",
+ })
+ return args
+
+@webnotes.whitelist()
+def get_invoices(start=0):
+ return get_transaction_list("Sales Invoice", start)
+
+def invoice_list_args():
+ args = get_common_args()
+ args.update({
+ "title": "Invoices",
+ "method": "website.helpers.transaction.get_invoices",
+ "icon": "icon-file-text",
+ "empty_list_message": "No Invoices Found",
+ "page": "invoice"
+ })
+ return args
\ No newline at end of file
diff --git a/website/templates/html/outer.html b/website/templates/html/outer.html
index 0f0f400..8e26f09 100644
--- a/website/templates/html/outer.html
+++ b/website/templates/html/outer.html
@@ -10,8 +10,7 @@
<a id="login-link" href="login">Login</a>
</div>
<div class="pull-right hide" style="margin:4px;" id="user-tools-post-login">
- <a href="profile" title="My Profile" id="user-full-name"></a> |
- <a href="account" title="My Account">My Account</a> |
+ <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> |
diff --git a/website/templates/pages/account.html b/website/templates/pages/account.html
index 539e014..6dcc497 100644
--- a/website/templates/pages/account.html
+++ b/website/templates/pages/account.html
@@ -8,12 +8,23 @@
<li><a href="index">Home</a></li>
<li class="active">My Account</li>
</ul>
- <h3>My Account</h3>
- <p><a href="profile"><i class="icon-user icon-fixed-width"></i> Change my name, password</a></p>
- <p><a href="addresses"><i class="icon-map-marker icon-fixed-width"></i> My Addresses</a></p>
- <p><a href="orders"><i class="icon-list icon-fixed-width"></i> My Orders</a></p>
- <p><a href="tickets"><i class="icon-tags icon-fixed-width"></i> My Tickets</a></p>
- <p><a href="server.py?cmd=web_logout"><i class="icon-signout icon-fixed-width"></i> Logout</a></p>
+ <!-- <h3>My Account</h3> -->
+ <ul class="nav nav-stacked pull-left">
+ <li><a href="profile"><i class="icon-user icon-fixed-width"></i>
+ Change my name, password</a></li>
+ <li><a href="addresses"><i class="icon-map-marker icon-fixed-width"></i>
+ My Addresses</a></li>
+ <li><a href="orders"><i class="icon-list icon-fixed-width"></i> My Orders</a></li>
+ <li><a href="tickets"><i class="icon-tags icon-fixed-width"></i> My Tickets</a></li>
+ <li style="border-top: 1px solid #ddd"></li>
+ <li><a href="messages"><i class="icon-comments icon-fixed-width"></i> Messages</a></li>
+ <li><a href="quotations"><i class="icon-shopping-cart icon-fixed-width"></i>
+ Quotations</a></li>
+ <li><a href="invoices"><i class="icon-file-text icon-fixed-width"></i> Invoices</a></li>
+ <li><a href="delivery_notes"><i class="icon-truck icon-fixed-width"></i> Shipments</a></li>
+ <li style="border-top: 1px solid #ddd"></li>
+ <li><a href="server.py?cmd=web_logout"><i class="icon-signout icon-fixed-width"></i>
+ Logout</a></li>
</ul>
</div>
{% endblock %}
\ No newline at end of file
diff --git a/website/templates/pages/address.html b/website/templates/pages/address.html
index faf7bb0..6544b12 100644
--- a/website/templates/pages/address.html
+++ b/website/templates/pages/address.html
@@ -42,9 +42,9 @@
<li><a href="index">Home</a></li>
<li><a href="account">My Account</a></li>
<li><a href="addresses">My Addresses</a></li>
- <li class="active">{{ title }}</li>
+ <li class="active"><i class="icon-map-marker icon-fixed-width"></i> {{ title }}</li>
</ul>
- <h3><i class="icon-map-marker"></i> {{ title }}</h3>
+ <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>
diff --git a/website/templates/pages/addresses.html b/website/templates/pages/addresses.html
index 90d0d13..04fc47b 100644
--- a/website/templates/pages/addresses.html
+++ b/website/templates/pages/addresses.html
@@ -7,10 +7,8 @@
<ul class="breadcrumb">
<li><a href="index">Home</a></li>
<li><a href="account">My Account</a></li>
- <li class="active">My Addresses</li>
+ <li class="active"><i class="icon-map-marker icon-fixed-width"></i> My Addresses</li>
</ul>
- <h3><i class="icon-map-marker icon-fixed-width"></i> My Addresses</h3>
- <hr>
<p><a class="btn btn-default" href="address"><i class="icon-plus"> New Address</i></a></p>
<hr>
<div id="address-list">
diff --git a/website/templates/pages/order.html b/website/templates/pages/order.html
index 1893575..c70dcb1 100644
--- a/website/templates/pages/order.html
+++ b/website/templates/pages/order.html
@@ -8,9 +8,9 @@
<li><a href="index">Home</a></li>
<li><a href="account">My Account</a></li>
<li><a href="orders">My Orders</a></li>
- <li class="active">{{ doc.name }}</li>
+ <li class="active"><i class="icon-file icon-fixed-width"></i> {{ doc.name }}</li>
</ul>
- <h3><i class="icon-file"></i> {{ doc.name }}</h3>
+ <h3><i class="icon-file icon-fixed-width"></i> {{ doc.name }}</h3>
<hr>
{%- if doc.status -%}
<div style="font-size: 13px;">
diff --git a/website/templates/pages/orders.html b/website/templates/pages/orders.html
deleted file mode 100644
index e0bf4d7..0000000
--- a/website/templates/pages/orders.html
+++ /dev/null
@@ -1,70 +0,0 @@
-{% extends "app/website/templates/html/page.html" %}
-
-{% set title="My Orders" %}
-
-{% block content %}
-<script>
-global_number_format = "{{ global_number_format }}";
-currency = "{{ currency }}";
-wn.currency_symbols = {{ currency_symbols }};
-</script>
-<div class="col-md-12">
- <ul class="breadcrumb">
- <li><a href="index">Home</a> <span class="divider">/</span></li>
- <li><a href="account">My Account</a> <span class="divider">/</span></li>
- <li class="active">My Orders</li>
- </ul>
- <h3><i class="icon-list icon-fixed-width"></i> My Orders</h3>
- <hr>
- <div id="order-list" style="font-size: 13px;">
- <div class="progress progress-striped active">
- <div class="progress-bar progress-bar-info" style="width: 100%;"></div>
- </div>
- </div>
-</div>
-<script>
-$(document).ready(function() {
- var order_start = 0;
-
- wn.call({
- method: "selling.doctype.sales_order.sales_order.get_orders",
- args: {
- start: order_start
- },
- callback: function(r) {
- $("#order-list .progress").remove();
- var $list = $("#order-list");
-
- if(!(r.message && r.message.length)) {
- $list.html("<div class='alert'>No Orders Yet</div>");
- return;
- }
-
- $.each(r.message, function(i, order) {
-
- // parent
- var $order = $(repl('<div class="row">\
- <div class="col-md-3"><a href="order?name=%(name)s">%(name)s</a></div>\
- <div class="col-md-9"></div>\
- </div>', order)).appendTo($list);
-
- // items
- $.each(order.items || [], function(i, item) {
- item.export_rate = format_currency(item.export_rate, order.currency);
- item.export_amount = format_currency(item.export_amount, order.currency);
- var $item = $(repl('<div class="row">\
- <div class="col-md-3">%(item_name)s</div>\
- <div class="col-md-2" style="text-align: right;">%(export_rate)s</div>\
- <div class="col-md-2" style="text-align: right;">%(qty)s %(stock_uom)s</div>\
- <div class="col-md-2" style="text-align: right;">%(export_amount)s</div>\
- </div>\
- </div>', item)).appendTo($order.find(".col-md-9"));
- });
-
- $("<hr>").appendTo($list);
- });
- }
- })
-})
-</script>
-{% endblock %}
\ No newline at end of file
diff --git a/website/templates/pages/profile.html b/website/templates/pages/profile.html
index ea2433b..4c03b40 100644
--- a/website/templates/pages/profile.html
+++ b/website/templates/pages/profile.html
@@ -5,12 +5,10 @@
{% block content %}
<div class="col-md-12">
<ul class="breadcrumb">
- <li><a href="index">Home</a> <span class="divider">/</span></li>
- <li><a href="account">My Account</a> <span class="divider">/</span></li>
- <li class="active">My Profile</li>
+ <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>
- <h2><i class="icon-user"></i> My Profile</h2>
- <hr>
<div class="alert" id="message" style="display: none;"></div>
<form>
<fieldset>
diff --git a/website/templates/pages/ticket.html b/website/templates/pages/ticket.html
index 1ae2e88..2f85ac0 100644
--- a/website/templates/pages/ticket.html
+++ b/website/templates/pages/ticket.html
@@ -5,12 +5,12 @@
{% block content %}
<div class="col-md-12">
<ul class="breadcrumb">
- <li><a href="index">Home</a> <span class="divider">/</span></li>
- <li><a href="account">My Account</a> <span class="divider">/</span></li>
- <li><a href="tickets">My Tickets</a> <span class="divider">/</span></li>
- <li class="active">{{ doc.name }}</li>
+ <li><a href="index">Home</a></li>
+ <li><a href="account">My Account</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-file"></i> {{ doc.name }}</h3>
+ <h3><i class="icon-ticket icon-fixed-width"></i> {{ doc.name }}</h3>
<hr>
{%- if doc.status -%}
<div class="row">
diff --git a/website/templates/pages/tickets.html b/website/templates/pages/tickets.html
index 3d5cf21..9c476ff 100644
--- a/website/templates/pages/tickets.html
+++ b/website/templates/pages/tickets.html
@@ -7,10 +7,8 @@
<ul class="breadcrumb">
<li><a href="index">Home</a></li>
<li><a href="account">My Account</a></li>
- <li class="active">My Tickets</li>
+ <li class="active"><i class="icon-ticket icon-fixed-width"></i> My Tickets</li>
</ul>
- <h3><i class="icon-tags icon-fixed-width"></i> My Tickets</h3>
- <hr>
<div id="ticket-list" style="font-size: 13px;">
<div class="progress progress-striped active">
<div class="progress-bar progress-bar-info" style="width: 100%;"></div>
diff --git a/website/templates/pages/transaction_list.html b/website/templates/pages/transaction_list.html
new file mode 100644
index 0000000..e92764a
--- /dev/null
+++ b/website/templates/pages/transaction_list.html
@@ -0,0 +1,69 @@
+{% 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>
+
+<script>
+global_number_format = "{{ global_number_format }}";
+currency = "{{ currency }}";
+wn.currency_symbols = {{ currency_symbols }};
+
+$(document).ready(function() {
+ var start = 0;
+ var $list = $(".transaction-list");
+
+ var get_transactions = function() {
+ wn.call({
+ method: "{{ method }}",
+ args: { start: start },
+ callback: function(r) {
+ $list.find(".progress").remove();
+
+ 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();
+});
+</script>
+{% endblock %}
\ No newline at end of file