\
- ', data);
- }
- });
- wrapper.similar.run();
-}
\ No newline at end of file
diff --git a/erpnext/stock/doctype/item/template.html b/erpnext/stock/doctype/item/template.html
deleted file mode 100644
index 8a2f4a9731d..00000000000
--- a/erpnext/stock/doctype/item/template.html
+++ /dev/null
@@ -1,25 +0,0 @@
-
-
-
-
{{ doc.item_name }}
-
-
-
-
- {{ doc.long_description_html }}
-
-
-
-
-
More Categories
-
-
-
Similar Products
-
-
-
-
-
\ No newline at end of file
diff --git a/erpnext/website/product.py b/erpnext/website/product.py
new file mode 100644
index 00000000000..7c6603af7b6
--- /dev/null
+++ b/erpnext/website/product.py
@@ -0,0 +1,97 @@
+import webnotes
+
+@webnotes.whitelist(allow_guest=True)
+def get_product_list(args=None):
+ """
+ args = {
+ 'limit_start': 0,
+ 'limit_page_length': 20,
+ 'search': '',
+ 'product_group': '',
+ }
+ """
+ import webnotes
+ from webnotes.utils import cstr, cint
+
+ if not args: args = webnotes.form_dict
+
+ # dict to be passed to sql function
+ query_args = {
+ 'limit_start': cint(args.get('limit_start')),
+ 'limit_page_length': cint(args.get('limit_page_length'))
+ }
+
+ # base query
+ query = """\
+ select name, item_name, page_name, website_image,
+ description, web_short_description
+ from `tabItem`
+ where is_sales_item = 'Yes'
+ and docstatus = 0
+ and show_in_website = 1"""
+
+ # search term condition
+ if args.get('search'):
+ query += """
+ and (
+ web_short_description like %(search)s or
+ web_long_description like %(search)s or
+ description like %(search)s or
+ item_name like %(search)s or
+ name like %(search)s
+ )"""
+ query_args['search'] = "%" + cstr(args.get('search')) + "%"
+
+ # product group condition
+ if args.get('product_group') and args.get('product_group') != 'All Products':
+ query += """
+ and item_group = %(product_group)s"""
+ query_args['product_group'] = args.get('product_group')
+
+ # order by
+ query += """
+ order by item_name asc, name asc"""
+
+ if args.get('limit_page_length'):
+ query += """
+ limit %(limit_start)s, %(limit_page_length)s"""
+
+ return webnotes.conn.sql(query, query_args, as_dict=1)
+
+@webnotes.whitelist(allow_guest=True)
+def get_product_category_list():
+ import webnotes
+
+ result = webnotes.conn.sql("""\
+ select count(name) as items, item_group
+ from `tabItem`
+ where is_sales_item = 'Yes'
+ and docstatus = 0
+ and show_in_website = 1
+ group by item_group
+ order by items desc""", as_dict=1)
+
+ # add All Products link
+ total_count = sum((r.get('items') or 0 for r in result))
+ result = [{'items': total_count, 'item_group': 'All Products'}] + (result or [])
+
+ return result
+
+@webnotes.whitelist(allow_guest=True)
+def get_similar_product_list(args=None):
+ import webnotes
+
+ if not args: args = webnotes.form_dict
+
+ result = webnotes.conn.sql("""\
+ select name, item_name, page_name, website_image,
+ description, web_short_description
+ from `tabItem`
+ where is_sales_item = 'Yes'
+ and docstatus = 0
+ and show_in_website = 1
+ and name != %(product_name)s
+ and item_group = %(product_group)s
+ order by item_name""", args, as_dict=1)
+
+ return result
\ No newline at end of file
diff --git a/erpnext/website/templates/login/login.html b/erpnext/website/templates/login/login.html
new file mode 100644
index 00000000000..834fc27067e
--- /dev/null
+++ b/erpnext/website/templates/login/login.html
@@ -0,0 +1,53 @@
+{% extends "login/login.js" %}
+
+{% block css %}
+
+{% endblock %}
+
+{% block content %}
+
+
+
+
+
Forgot Password
+
+
+
+{% endblock %}
\ No newline at end of file
diff --git a/erpnext/website/templates/login/login.js b/erpnext/website/templates/login/login.js
new file mode 100644
index 00000000000..d6b6b24147a
--- /dev/null
+++ b/erpnext/website/templates/login/login.js
@@ -0,0 +1,103 @@
+{% extends "page.html" %}
+
+{% block javascript %}
+{{ super() }}
+// Copyright (c) 2012 Web Notes Technologies Pvt Ltd (http://erpnext.com)
+//
+// MIT License (MIT)
+//
+// Permission is hereby granted, free of charge, to any person obtaining a
+// copy of this software and associated documentation files (the "Software"),
+// to deal in the Software without restriction, including without limitation
+// the rights to use, copy, modify, merge, publish, distribute, sublicense,
+// and/or sell copies of the Software, and to permit persons to whom the
+// Software is furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
+// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
+// PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
+// CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
+// OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+wn.provide('erpnext.login');
+
+wn.pages["{{ name }}"].onload = function(wrapper) {
+ wrapper.appframe = new wn.ui.AppFrame($(wrapper).find('.appframe-area'));
+ wrapper.appframe.title('Login');
+ wrapper.appframe.$w.find('.close').toggle(false);
+
+ var lw = $i('login_wrapper');
+ $bs(lw, '1px 1px 3px #888');
+
+ $('#login_btn').click(erpnext.login.doLogin)
+
+ $('#password').keypress(function(ev){
+ if(ev.which==13 && $('#password').val()) {
+ $('form').submit(function() {
+ erpnext.login.doLogin();
+ return false;
+ });
+ }
+ });
+ $(document).trigger('login_rendered');
+}
+
+// Login Callback
+erpnext.login.onLoginReply = function(r, rtext) {
+ $('#login_btn').done_working();
+ if(r.message=="Logged In"){
+ window.location.href='app.html' + (get_url_arg('page') ? ('?page='+get_url_arg('page')) : '');
+ } else {
+ $i('login_message').innerHTML = ''+(r.message)+'';
+ //if(r.exc)alert(r.exc);
+ }
+}
+
+
+// Login
+erpnext.login.doLogin = function(){
+
+ var args = {};
+ args['usr']=$i("login_id").value;
+ args['pwd']=$i("password").value;
+ if($i('remember_me').checked)
+ args['remember_me'] = 1;
+
+ $('#login_btn').set_working();
+
+ $c("login", args, erpnext.login.onLoginReply);
+
+ return false;
+}
+
+
+erpnext.login.show_forgot_password = function(){
+ // create dialog
+ var d = new wn.ui.Dialog({
+ title:"Forgot Password",
+ fields: [
+ {'label':'Email Id', 'fieldname':'email_id', 'fieldtype':'Data', 'reqd':true},
+ {'label':'Email Me A New Password', 'fieldname':'run', 'fieldtype':'Button'}
+ ]
+ });
+
+ $(d.fields_dict.run.input).click(function() {
+ var values = d.get_values();
+ if(!values) return;
+ wn.call({
+ method:'reset_password',
+ args: { user: values.email_id },
+ callback: function() {
+ d.hide();
+ }
+ })
+ })
+ d.show();
+}
+
+{% endblock %}
\ No newline at end of file
diff --git a/erpnext/website/templates/product/product.html b/erpnext/website/templates/product/product.html
index 5d3c3da980d..6f33ec95085 100644
--- a/erpnext/website/templates/product/product.html
+++ b/erpnext/website/templates/product/product.html
@@ -1,23 +1,30 @@
{% extends "product/product.js" %}
-{% block title %}{{ item_name }} [{{ name }}]{% endblock %}
+{% block title %}
+ {% if item_name != name %}
+ {{ item_name }} [{{ name }}]
+ {% else %}
+ {{ item_name }}
+ {% endif %}
+{% endblock %}
{% block content %}
{{ item_name }}
-
+
{% if website_image %}
-
-
+
+ {% else %}
+
+ This is an auto-generated Image
{% endif %}
+
+
{{ web_description_html }}
-
+
@@ -31,3 +38,40 @@
{% endblock %}
+
+{% block css %}
+
+{% endblock %}
diff --git a/erpnext/website/templates/product/product.js b/erpnext/website/templates/product/product.js
index 3475204413c..9e51334b8e4 100644
--- a/erpnext/website/templates/product/product.js
+++ b/erpnext/website/templates/product/product.js
@@ -22,52 +22,60 @@ wn.pages['{{ name }}'].onload = function(wrapper) {
wrapper.product_group = "{{ item_group }}";
wrapper.product_name = "{{ name }}";
erpnext.products.make_product_categories(wrapper);
+ erpnext.products.make_similar_products(wrapper);
+
+ // if website image missing, autogenerate one
+ var $img = $('.product-page-content').find('.img-area');
+ if ($img && $img.length > 0) {
+ $img.append(wn.dom.placeholder(160, "{{ item_name }}"));
+ }
- // TODO make this working
- $(wrapper).find('.product-inquiry').click(function() {
- loadpage('contact', function() {
- $('#content-contact-us [name="contact-message"]').val("Hello,\n\n\
- Please send me more information on {{ item_name }} (Item Code:{{ name }})\n\n\
- My contact details are:\n\nThank you!\
- ");
- })
- });
+ // adjust page height based on sidebar height
+ var $main_page = $('.layout-main-section');
+ var $sidebar = $('.layout-side-section');
+ if ($sidebar.height() > $main_page.height()) {
+ $main_page.height($sidebar.height());
+ }
+
+}
+
+erpnext.products.make_similar_products = function(wrapper) {
+ if (!wrapper) { wrapper = erpnext.products.wrapper; }
+ if (!wrapper) { return; }
// similar products
wrapper.similar = new wn.ui.Listing({
parent: $(wrapper).find('.similar-products').get(0),
hide_refresh: true,
page_length: 5,
- get_query: function() {
- args = {
- cat: wrapper.product_group,
- name: wrapper.product_name
- };
- var query = repl('select name, item_name, website_image, \
- page_name, description \
- from tabItem \
- where is_sales_item="Yes" \
- and ifnull(show_in_website, "No")="Yes" \
- and name != "%(name)s" and docstatus = 0 \
- and item_group="%(cat)s" order by modified desc', args)
- return query
+ method: 'website.product.get_similar_product_list',
+ get_args: function() {
+ return {
+ product_group: wrapper.product_group,
+ product_name: wrapper.product_name
+ }
},
render_row: function(parent, data) {
- if(data.description.length > 100) {
- data.description = data.description.substr(0,100) + '...';
+ if (!data.web_short_description) {
+ data.web_short_description = data.description;
+ }
+ if(data.web_short_description.length > 100) {
+ data.web_short_description =
+ data.web_short_description.substr(0,100) + '...';
}
parent.innerHTML = repl('\
- \
-