[minor] customer login start
This commit is contained in:
parent
4b29c89692
commit
f7e5648365
@ -106,8 +106,13 @@
|
||||
},
|
||||
"orders": {
|
||||
"no_cache": true,
|
||||
"template": "app/website/templates/pages/orders",
|
||||
"args_method": "selling.doctype.sales_order.sales_order.get_currency_and_number_format"
|
||||
"template": "app/website/templates/pages/transaction_list",
|
||||
"args_method": "website.helpers.transaction.order_list_args"
|
||||
},
|
||||
"invoices": {
|
||||
"no_cache": true,
|
||||
"template": "app/website/templates/pages/transaction_list",
|
||||
"args_method": "website.helpers.transaction.invoice_list_args"
|
||||
},
|
||||
"product_search": {
|
||||
"template": "app/website/templates/pages/product_search"
|
||||
|
@ -7,8 +7,7 @@
|
||||
"app/public/js/startup.css"
|
||||
],
|
||||
"public/js/all-web.min.js": [
|
||||
"app/public/js/website_utils.js",
|
||||
"lib/public/js/wn/misc/number_format.js"
|
||||
"app/public/js/website_utils.js"
|
||||
],
|
||||
"public/js/all-app.min.js": [
|
||||
"app/public/js/startup.js",
|
||||
|
@ -4,7 +4,6 @@
|
||||
from __future__ import unicode_literals
|
||||
import webnotes
|
||||
import webnotes.utils
|
||||
import json
|
||||
|
||||
from webnotes.utils import cstr, flt, getdate
|
||||
from webnotes.model.bean import getlist
|
||||
@ -287,31 +286,6 @@ class DocType(SellingController):
|
||||
def on_update(self):
|
||||
pass
|
||||
|
||||
@webnotes.whitelist()
|
||||
def get_orders():
|
||||
# find customer id
|
||||
customer = webnotes.conn.get_value("Contact", {"email_id": webnotes.session.user},
|
||||
"customer")
|
||||
|
||||
if customer:
|
||||
orders = webnotes.conn.sql("""select
|
||||
name, creation, currency from `tabSales Order`
|
||||
where customer=%s
|
||||
and docstatus=1
|
||||
order by creation desc
|
||||
limit 20
|
||||
""", customer, as_dict=1)
|
||||
for order in orders:
|
||||
order.items = webnotes.conn.sql("""select
|
||||
item_name, qty, export_rate, export_amount, delivered_qty, stock_uom
|
||||
from `tabSales Order Item`
|
||||
where parent=%s
|
||||
order by idx""", order.name, as_dict=1)
|
||||
|
||||
return orders
|
||||
else:
|
||||
return []
|
||||
|
||||
def get_website_args():
|
||||
customer = webnotes.conn.get_value("Contact", {"email_id": webnotes.session.user},
|
||||
"customer")
|
||||
@ -325,17 +299,9 @@ def get_website_args():
|
||||
"doc": bean.doc,
|
||||
"doclist": bean.doclist,
|
||||
"webnotes": webnotes,
|
||||
"utils": webnotes.utils
|
||||
"utils": webnotes.utils,
|
||||
}
|
||||
|
||||
def get_currency_and_number_format():
|
||||
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""")))
|
||||
}
|
||||
|
||||
def set_missing_values(source, target):
|
||||
bean = webnotes.bean(target)
|
||||
bean.run_method("onload_post_render")
|
||||
|
63
website/helpers/transaction.py
Normal file
63
website/helpers/transaction.py
Normal file
@ -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
|
@ -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> |
|
||||
|
@ -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 %}
|
@ -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>
|
||||
|
@ -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">
|
||||
|
@ -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;">
|
||||
|
@ -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 %}
|
@ -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>
|
||||
|
@ -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">
|
||||
|
@ -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>
|
||||
|
69
website/templates/pages/transaction_list.html
Normal file
69
website/templates/pages/transaction_list.html
Normal file
@ -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 %}
|
Loading…
Reference in New Issue
Block a user