website: made order and ticket listing
This commit is contained in:
parent
11394f0986
commit
da512ba8c9
@ -98,7 +98,8 @@
|
||||
{{ doc.terms }}
|
||||
</td>
|
||||
<td>
|
||||
<table cellspacing=0 width=100%><tbody>
|
||||
<table cellspacing=0 width=100%>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>Net Total</td>
|
||||
<td width=40% style="text-align: right;">{{
|
||||
@ -121,7 +122,8 @@
|
||||
<td>Rounded Total</td>
|
||||
<td style="text-align: right;">{{ utils.fmt_money(doc.rounded_total_export, currency=doc.currency) }}</td>
|
||||
</tr>
|
||||
</tbody></table>
|
||||
</tbody>
|
||||
</table>
|
||||
<br /><b>In Words</b><br />
|
||||
<i>{{ doc.in_words_export }}</i>
|
||||
</td>
|
||||
|
@ -7,7 +7,8 @@
|
||||
"app/public/js/startup.css"
|
||||
],
|
||||
"public/js/all-web.min.js": [
|
||||
"app/public/js/website_utils.js"
|
||||
"app/public/js/website_utils.js",
|
||||
"lib/public/js/wn/misc/number_format.js"
|
||||
],
|
||||
"public/js/all-app.min.js": [
|
||||
"app/public/js/startup.js",
|
||||
|
@ -72,7 +72,7 @@ $(document).ready(function() {
|
||||
if(full_name) {
|
||||
$("#user-tools").html(repl('<a href="profile" title="My Profile" id="user-full-name">%(full_name)s</a> | \
|
||||
<a href="account" title="My Account">My Account</a> | \
|
||||
<a href="cart" title="Shopping Cart"><i class="icon-shopping-cart"></i> (%(count)s)</a> | \
|
||||
<!--<a href="cart" title="Shopping Cart"><i class="icon-shopping-cart"></i> (%(count)s)</a> | -->\
|
||||
<a href="server.py?cmd=web_logout" title="Sign Out"><i class="icon-signout"></i></a>', {
|
||||
full_name: full_name,
|
||||
count: getCookie("cart_count") || "0"
|
||||
@ -108,6 +108,10 @@ function repl(s, dict) {
|
||||
return s;
|
||||
}
|
||||
|
||||
function replace_all(s, t1, t2) {
|
||||
return s.split(t1).join(t2);
|
||||
}
|
||||
|
||||
function getCookie(name) {
|
||||
return getCookies()[name];
|
||||
}
|
||||
|
@ -16,6 +16,8 @@
|
||||
|
||||
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
|
||||
@ -361,11 +363,43 @@ def get_orders():
|
||||
"customer")
|
||||
|
||||
if customer:
|
||||
orders = webnotes.conn.sql("""select name, creation, currency from `tabSales Order`
|
||||
where customer=%s""", customer, as_dict=1)
|
||||
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, delivered_qty
|
||||
from `tabSales Order Item` where parent=%s order by idx""", order.name, as_dict=1)
|
||||
order.items = webnotes.conn.sql("""select
|
||||
item_name, qty, export_rate, delivered_qty, stock_uom
|
||||
from `tabSales Order Item`
|
||||
where parent=%s
|
||||
order by idx""", order.name, as_dict=1)
|
||||
return orders
|
||||
else:
|
||||
return []
|
||||
return []
|
||||
|
||||
def get_website_args():
|
||||
customer = webnotes.conn.get_value("Contact", {"email_id": webnotes.session.user},
|
||||
"customer")
|
||||
bean = webnotes.bean("Sales Order", webnotes.form_dict.name)
|
||||
if bean.doc.customer != customer:
|
||||
return {
|
||||
"doc": {"name": "Not Allowed"}
|
||||
}
|
||||
else:
|
||||
return {
|
||||
"doc": bean.doc,
|
||||
"doclist": bean.doclist,
|
||||
"webnotes": webnotes,
|
||||
"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""")))
|
||||
}
|
@ -73,8 +73,25 @@ def set_status(name, status):
|
||||
|
||||
@webnotes.whitelist()
|
||||
def get_tickets():
|
||||
tickets = webnotes.conn.sql("""select name, subject, status from
|
||||
`tabSupport Ticket` where raised_by=%s order by modified desc""",
|
||||
tickets = webnotes.conn.sql("""select
|
||||
name, subject, status
|
||||
from `tabSupport Ticket`
|
||||
where raised_by=%s
|
||||
order by modified desc
|
||||
limit 20""",
|
||||
webnotes.session.user, as_dict=1)
|
||||
return tickets
|
||||
|
||||
def get_website_args():
|
||||
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
|
||||
}
|
||||
|
33
website/settings.py
Normal file
33
website/settings.py
Normal file
@ -0,0 +1,33 @@
|
||||
import webnotes
|
||||
|
||||
page_map = {
|
||||
'Web Page': webnotes._dict({
|
||||
"template": 'html/web_page.html',
|
||||
"condition_field": "published"
|
||||
}),
|
||||
'Blog Post': webnotes._dict({
|
||||
"template": 'html/blog_page.html',
|
||||
"condition_field": "published",
|
||||
}),
|
||||
'Item': webnotes._dict({
|
||||
"template": 'html/product_page.html',
|
||||
"condition_field": "show_in_website",
|
||||
}),
|
||||
'Item Group': webnotes._dict({
|
||||
"template": "html/product_group.html",
|
||||
"condition_field": "show_in_website"
|
||||
})
|
||||
}
|
||||
|
||||
page_settings_map = {
|
||||
"about": "website.doctype.about_us_settings.about_us_settings.get_args",
|
||||
"contact": "Contact Us Settings",
|
||||
"blog": "website.helpers.blog.get_blog_template_args",
|
||||
"writers": "website.helpers.blog.get_writers_args",
|
||||
"print": "core.doctype.print_format.print_format.get_args",
|
||||
"orders": "selling.doctype.sales_order.sales_order.get_currency_and_number_format",
|
||||
"order": "selling.doctype.sales_order.sales_order.get_website_args",
|
||||
"ticket": "support.doctype.support_ticket.support_ticket.get_website_args"
|
||||
}
|
||||
|
||||
no_cache = ["message", "print"]
|
@ -1,12 +1,88 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Print Format</title>
|
||||
<meta name="generator" content="wnframework">
|
||||
</head>
|
||||
<body>
|
||||
{{ webnotes.form_dict }}
|
||||
</body>
|
||||
</html>
|
||||
{% extends "html/page.html" %}
|
||||
|
||||
{% set title=doc.name %}
|
||||
|
||||
{% block content %}
|
||||
<div class="span12">
|
||||
<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="orders">My Orders</a> <span class="divider">/</span></li>
|
||||
<li class="active">{{ doc.name }}</li>
|
||||
</ul>
|
||||
<h3><i class="icon-file"></i> {{ doc.name }}</h3>
|
||||
<hr>
|
||||
{%- if doc.status -%}
|
||||
<div style="font-size: 13px;">
|
||||
<div class="row">
|
||||
<div class="span2">
|
||||
<div class="label">{{ doc.status }}</div>
|
||||
</div>
|
||||
<div class="span4">
|
||||
{{ utils.formatdate(doc.transaction_date) }}
|
||||
</div>
|
||||
</div>
|
||||
<br>
|
||||
<div class="row">
|
||||
<div class="span12">
|
||||
<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="span6"></div>
|
||||
<div class="span6">
|
||||
<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 %}
|
@ -3,6 +3,11 @@
|
||||
{% set title="My Orders" %}
|
||||
|
||||
{% block content %}
|
||||
<script>
|
||||
global_number_format = "{{ global_number_format }}";
|
||||
currency = "{{ currency }}";
|
||||
wn.currency_symbols = {{ currency_symbols }};
|
||||
</script>
|
||||
<div class="span12">
|
||||
<ul class="breadcrumb">
|
||||
<li><a href="index">Home</a> <span class="divider">/</span></li>
|
||||
@ -39,18 +44,19 @@ $(document).ready(function() {
|
||||
|
||||
// parent
|
||||
var $order = $(repl('<div class="row">\
|
||||
<div class="span4"><a href="order?id=%(name)s">%(name)s</a></span3>\
|
||||
<div class="span4"><a href="order?name=%(name)s">%(name)s</a></div>\
|
||||
<div class="span8"></div>\
|
||||
</div>', order)).appendTo($list);
|
||||
|
||||
// items
|
||||
$.each(order.items || [], function(i, item) {
|
||||
var $item = $(repl('<div class="span8">\
|
||||
<div class="row">\
|
||||
item.export_rate = format_currency(item.export_rate, order.currency);
|
||||
var $item = $(repl('<div class="row">\
|
||||
<div class="span4">%(item_name)s</div>\
|
||||
<div class="span2">%(export_rate)s</div>\
|
||||
<div class="span2">%(status)s</div>\
|
||||
<div class="span2" style="text-align: right;">%(qty)s %(stock_uom)s</div>\
|
||||
<div class="span2" style="text-align: right;">%(export_rate)s</div>\
|
||||
</div>\
|
||||
</div>', item)).appendTo($order);
|
||||
</div>', item)).appendTo($order.find(".span8"));
|
||||
});
|
||||
|
||||
$("<hr>").appendTo($list);
|
||||
|
49
website/templates/pages/ticket.html
Normal file
49
website/templates/pages/ticket.html
Normal file
@ -0,0 +1,49 @@
|
||||
{% extends "html/page.html" %}
|
||||
|
||||
{% set title=doc.name %}
|
||||
|
||||
{% block content %}
|
||||
<div class="span12">
|
||||
<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>
|
||||
</ul>
|
||||
<h3><i class="icon-file"></i> {{ doc.name }}</h3>
|
||||
<hr>
|
||||
{%- if doc.status -%}
|
||||
<div class="row">
|
||||
<div class="span2">
|
||||
<div class="label">{{ doc.status }}</div>
|
||||
</div>
|
||||
<div class="span7">
|
||||
{{ doc.subject }}
|
||||
</div>
|
||||
<div class="span3">
|
||||
{{ utils.formatdate(doc.transaction_date) }}
|
||||
</div>
|
||||
</div>
|
||||
<br>
|
||||
<h4>Messages</h4>
|
||||
{%- if doclist.get({"doctype":"Communication"}) -%}
|
||||
<div style="font-size: 13px;">
|
||||
<table class="table table-bordered table-striped">
|
||||
<tbody>
|
||||
{%- for comm in doclist.get({"doctype":"Communication"}) %}
|
||||
<tr>
|
||||
<td>
|
||||
<h5>{{ comm.sender }} on {{ utils.formatdate(doc.modified) }}</h5>
|
||||
<p>{{ comm.content }}</p>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor -%}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
{%- else -%}
|
||||
<div class="alert">No messages</div>
|
||||
{%- endif -%}
|
||||
{%- endif -%}
|
||||
</div>
|
||||
{% endblock %}
|
@ -1,6 +1,6 @@
|
||||
{% extends "html/page.html" %}
|
||||
|
||||
{% set title="My Orders" %}
|
||||
{% set title="My Tickets" %}
|
||||
|
||||
{% block content %}
|
||||
<div class="span12">
|
||||
@ -40,7 +40,7 @@ $(document).ready(function() {
|
||||
// parent
|
||||
var $ticket = $(repl('<div class="row">\
|
||||
<div class="span2"><span class="label">%(status)s</span></div>\
|
||||
<div class="span3"><a href="ticket?id=%(name)s">%(name)s</a></div>\
|
||||
<div class="span3"><a href="ticket?name=%(name)s">%(name)s</a></div>\
|
||||
<div class="span7">%(subject)s</div>\
|
||||
</div>', ticket)).appendTo($list);
|
||||
|
||||
|
@ -18,36 +18,9 @@ from __future__ import unicode_literals
|
||||
|
||||
import os
|
||||
import conf
|
||||
from website.settings import *
|
||||
import webnotes
|
||||
|
||||
page_map = {
|
||||
'Web Page': webnotes._dict({
|
||||
"template": 'html/web_page.html',
|
||||
"condition_field": "published"
|
||||
}),
|
||||
'Blog Post': webnotes._dict({
|
||||
"template": 'html/blog_page.html',
|
||||
"condition_field": "published",
|
||||
}),
|
||||
'Item': webnotes._dict({
|
||||
"template": 'html/product_page.html',
|
||||
"condition_field": "show_in_website",
|
||||
}),
|
||||
'Item Group': webnotes._dict({
|
||||
"template": "html/product_group.html",
|
||||
"condition_field": "show_in_website"
|
||||
})
|
||||
}
|
||||
|
||||
page_settings_map = {
|
||||
"about": "website.doctype.about_us_settings.about_us_settings.get_args",
|
||||
"contact": "Contact Us Settings",
|
||||
"blog": "website.helpers.blog.get_blog_template_args",
|
||||
"writers": "website.helpers.blog.get_writers_args",
|
||||
"print": "core.doctype.print_format.print_format.get_args"
|
||||
}
|
||||
|
||||
no_cache = ["message", "print"]
|
||||
import webnotes.utils
|
||||
|
||||
def render(page_name):
|
||||
"""render html page"""
|
||||
@ -257,7 +230,8 @@ def get_outer_env(page_name, args):
|
||||
order by idx asc""", as_dict=1),
|
||||
|
||||
'int':int,
|
||||
"webnotes": webnotes
|
||||
"webnotes": webnotes,
|
||||
"utils": webnotes.utils
|
||||
})
|
||||
|
||||
args.update(ret)
|
||||
|
Loading…
x
Reference in New Issue
Block a user