From a9c0f5de7d8621ff2e5859d328fb33820bec9c42 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Thu, 5 Sep 2013 12:19:00 +0530 Subject: [PATCH] [feature] [customer login] send links in email for portal access of Sales Order, Sales Invoice, Delivery Note and Suppor Ticket --- config.json | 25 +++++- public/js/website_utils.js | 12 ++- website/templates/pages/sale.html | 4 + website/templates/pages/ticket.html | 5 ++ website/templates/pages/transaction_list.html | 77 +++++++++++++++++++ 5 files changed, 117 insertions(+), 6 deletions(-) create mode 100644 website/templates/pages/transaction_list.html diff --git a/config.json b/config.json index d30c6976e0..e0f98d8daa 100644 --- a/config.json +++ b/config.json @@ -103,7 +103,12 @@ "no_cache": true, "template": "app/website/templates/pages/sale", "args_method": "website.helpers.transaction.get_order_args", - "for_doctype": "Sales Order" + "portal": { + "doctype": "Sales Order", + "conditions": { + "docstatus": 1 + } + } }, "orders": { "no_cache": true, @@ -114,7 +119,12 @@ "no_cache": true, "template": "app/website/templates/pages/sale", "args_method": "website.helpers.transaction.get_invoice_args", - "for_doctype": "Sales Invoice" + "portal": { + "doctype": "Sales Invoice", + "conditions": { + "docstatus": 1 + } + } }, "invoices": { "no_cache": true, @@ -125,7 +135,12 @@ "no_cache": true, "template": "app/website/templates/pages/sale", "args_method": "website.helpers.transaction.get_shipment_args", - "for_doctype": "Delivery Note" + "portal": { + "doctype": "Delivery Note", + "conditions": { + "docstatus": 1 + } + } }, "shipments": { "no_cache": true, @@ -139,7 +154,9 @@ "no_cache": true, "template": "app/website/templates/pages/ticket", "args_method": "support.doctype.support_ticket.support_ticket.get_website_args", - "for_doctype": "Support Ticket" + "portal": { + "doctype": "Support Ticket" + } }, "tickets": { "template": "app/website/templates/pages/tickets", diff --git a/public/js/website_utils.js b/public/js/website_utils.js index 1b7f0f728d..9b7832678a 100644 --- a/public/js/website_utils.js +++ b/public/js/website_utils.js @@ -1,7 +1,6 @@ // Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. // License: GNU General Public License v3. See license.txt - if(!window.erpnext) erpnext = {}; if(!window.wn) wn = {}; @@ -200,7 +199,7 @@ $.extend(wn.cart, { update_cart: function(opts) { if(!full_name) { if(localStorage) { - localStorage.setItem("last_visited", window.location.pathname.slice(1)); + localStorage.setItem("last_visited", window.location.href.split("/").slice(-1)[0]); localStorage.setItem("pending_add_to_cart", opts.item_code); } window.location.href = "login"; @@ -242,4 +241,13 @@ function is_html(txt) { return false; } return true; +} + +function ask_to_login() { + if(!full_name) { + if(localStorage) { + localStorage.setItem("last_visited", window.location.href.split("/").slice(-1)[0]); + } + window.location.href = "login"; + } } \ No newline at end of file diff --git a/website/templates/pages/sale.html b/website/templates/pages/sale.html index 669a3807f8..1c03da261a 100644 --- a/website/templates/pages/sale.html +++ b/website/templates/pages/sale.html @@ -11,6 +11,9 @@
  • {{ doc.name }}
  • {{ doc.name }}

    + {% if doc.name == "Not Allowed" -%} + + {% else %}
    @@ -82,5 +85,6 @@
    + {%- endif %} {% endblock %} \ No newline at end of file diff --git a/website/templates/pages/ticket.html b/website/templates/pages/ticket.html index eeb485a064..6622ed1589 100644 --- a/website/templates/pages/ticket.html +++ b/website/templates/pages/ticket.html @@ -17,6 +17,9 @@
  • {{ doc.name }}
  • {{ doc.name }}

    + {% if doc.name == "Not Allowed" -%} + + {% else %}
    {%- if doc.status -%} {% if doc.status == "Waiting for Customer" -%} @@ -46,6 +49,7 @@
    {{ comm.sender }} on {{ utils.formatdate(doc.modified) }}
    +

    {{ webnotes.utils.is_html(comm.content) and comm.content or comm.content.replace("\n", "
    ")}}

    @@ -58,5 +62,6 @@
    No messages
    {%- endif -%} {%- endif -%} + {% endif -%} {% endblock %} \ No newline at end of file diff --git a/website/templates/pages/transaction_list.html b/website/templates/pages/transaction_list.html new file mode 100644 index 0000000000..967a6a8324 --- /dev/null +++ b/website/templates/pages/transaction_list.html @@ -0,0 +1,77 @@ +{% extends "app/website/templates/html/page.html" %} + +{% block content %} +
    + +
    +
    +
    +
    +
    +
    +
    +
    +{% 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("
    \ + {{ empty_list_message }}
    "); + } + 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('\ +
    \ +
    \ +
    %(name)s
    \ +
    %(items)s...
    \ +
    \ +
    %(grand_total_export)s
    \ +
    %(creation)s
    \ +
    \ +
    ', doc)).appendTo($list); + }; + + get_transactions(); +}); +{% endblock %} \ No newline at end of file