From da512ba8c9345459ae972ca357f1cf8765a8387e Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Fri, 22 Mar 2013 12:45:44 +0530 Subject: [PATCH] website: made order and ticket listing --- .../SalesInvoice/SalesInvoice.html | 6 +- public/build.json | 3 +- public/js/website_utils.js | 6 +- selling/doctype/sales_order/sales_order.py | 44 +++++++- .../doctype/support_ticket/support_ticket.py | 21 +++- website/settings.py | 33 ++++++ website/templates/pages/order.html | 100 +++++++++++++++--- website/templates/pages/orders.html | 18 ++-- website/templates/pages/ticket.html | 49 +++++++++ website/templates/pages/tickets.html | 4 +- website/utils.py | 34 +----- 11 files changed, 257 insertions(+), 61 deletions(-) create mode 100644 website/settings.py create mode 100644 website/templates/pages/ticket.html diff --git a/accounts/Print Format/SalesInvoice/SalesInvoice.html b/accounts/Print Format/SalesInvoice/SalesInvoice.html index 6acdc52ba90..2b08197ed26 100644 --- a/accounts/Print Format/SalesInvoice/SalesInvoice.html +++ b/accounts/Print Format/SalesInvoice/SalesInvoice.html @@ -98,7 +98,8 @@ {{ doc.terms }} - +
+ -
Net Total {{ @@ -121,7 +122,8 @@ Rounded Total {{ utils.fmt_money(doc.rounded_total_export, currency=doc.currency) }}
+ +
In Words
{{ doc.in_words_export }} diff --git a/public/build.json b/public/build.json index 121d333f972..05d603f4b92 100644 --- a/public/build.json +++ b/public/build.json @@ -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", diff --git a/public/js/website_utils.js b/public/js/website_utils.js index 8462c3d98cd..a33eee04baf 100644 --- a/public/js/website_utils.js +++ b/public/js/website_utils.js @@ -72,7 +72,7 @@ $(document).ready(function() { if(full_name) { $("#user-tools").html(repl('%(full_name)s | \ My Account | \ - (%(count)s) | \ + \ ', { 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]; } diff --git a/selling/doctype/sales_order/sales_order.py b/selling/doctype/sales_order/sales_order.py index 91b88a406ed..67dcb1dd392 100644 --- a/selling/doctype/sales_order/sales_order.py +++ b/selling/doctype/sales_order/sales_order.py @@ -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 [] \ No newline at end of file + 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"""))) + } \ No newline at end of file diff --git a/support/doctype/support_ticket/support_ticket.py b/support/doctype/support_ticket/support_ticket.py index 1fe2c2d9d48..5625f1179cd 100644 --- a/support/doctype/support_ticket/support_ticket.py +++ b/support/doctype/support_ticket/support_ticket.py @@ -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 + } diff --git a/website/settings.py b/website/settings.py new file mode 100644 index 00000000000..d8c3d282d54 --- /dev/null +++ b/website/settings.py @@ -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"] diff --git a/website/templates/pages/order.html b/website/templates/pages/order.html index b8d96958858..9e80694f537 100644 --- a/website/templates/pages/order.html +++ b/website/templates/pages/order.html @@ -1,12 +1,88 @@ - - - - - - Print Format - - - - {{ webnotes.form_dict }} - - \ No newline at end of file +{% extends "html/page.html" %} + +{% set title=doc.name %} + +{% block content %} +
+ +

{{ doc.name }}

+
+ {%- if doc.status -%} +
+
+
+
{{ doc.status }}
+
+
+ {{ utils.formatdate(doc.transaction_date) }} +
+
+
+
+
+ + + + + + + + + + + + {%- for row in doclist.get({"doctype":"Sales Order Item"}) %} + + + + + + + + + + {% endfor -%} + +
SrItem NameDescriptionQtyUoMBasic RateAmount
{{ row.idx }}{{ row.item_name }}{{ row.description }}{{ row.qty }}{{ row.stock_uom }}{{ utils.fmt_money(row.export_rate, currency=doc.currency) }}{{ utils.fmt_money(row.export_amount, currency=doc.currency) }}
+
+
+
+
+
+ + + + + + + {%- for charge in doclist.get({"doctype":"Sales Taxes and Charges"}) -%} + {%- if not charge.included_in_print_rate -%} + + + + + {%- endif -%} + {%- endfor -%} + + + + + + + + + +
Net Total{{ + utils.fmt_money(doc.net_total/doc.conversion_rate, currency=doc.currency) + }}
{{ charge.description }}{{ utils.fmt_money(charge.tax_amount / doc.conversion_rate, currency=doc.currency) }}
Grand Total{{ utils.fmt_money(doc.grand_total_export, currency=doc.currency) }}
Rounded Total{{ utils.fmt_money(doc.rounded_total_export, currency=doc.currency) }}
+
+
+
+ {%- endif -%} +
+{% endblock %} \ No newline at end of file diff --git a/website/templates/pages/orders.html b/website/templates/pages/orders.html index 1a1cc37fe57..b1a3c7eb670 100644 --- a/website/templates/pages/orders.html +++ b/website/templates/pages/orders.html @@ -3,6 +3,11 @@ {% set title="My Orders" %} {% block content %} +