updates to item, item_group and website
This commit is contained in:
parent
608a751b57
commit
fc19f25c88
@ -26,18 +26,3 @@ cur_frm.fields_dict['project'].get_query = function(doc,cdt,cdn){
|
||||
cur_frm.cscript.project = function(doc, cdt, cdn){
|
||||
if(doc.project) get_server_fields('get_project_details', '','', doc, cdt, cdn, 1);
|
||||
}
|
||||
|
||||
|
||||
// TODO: remove these? field doesn't exist, but custom field could exist
|
||||
cur_frm.fields_dict['customer'].get_query = function(doc,cdt,cdn){
|
||||
var cond='';
|
||||
if(doc.project) cond = 'ifnull(`tabProject`.customer, "") = `tabCustomer`.name AND ifnull(`tabProject`.name, "") = "'+doc.project+'" AND';
|
||||
return repl('SELECT distinct `tabCustomer`.`name` FROM `tabCustomer`, `tabProject` WHERE %(cond)s `tabCustomer`.`name` LIKE "%s" ORDER BY `tabCustomer`.`name` ASC LIMIT 50', {cond:cond});
|
||||
}
|
||||
|
||||
cur_frm.cscript.customer = function(doc, cdt, cdn){
|
||||
if(doc.customer) get_server_fields('get_customer_details', '','', doc, cdt, cdn, 1);
|
||||
else doc.customer_name ='';
|
||||
}
|
||||
|
||||
|
||||
|
@ -39,6 +39,5 @@ class DocType(DocTypeNestedSet):
|
||||
|
||||
def prepare_template_args(self):
|
||||
self.doc.sub_groups = webnotes.conn.sql("""select name, page_name
|
||||
from `tabItem Group` where parent_item_group=%s
|
||||
and ifnull(show_in_website,0)=1""", self.doc.name, as_dict=1)
|
||||
|
||||
from `tabItem Group` where parent_item_group=%s
|
||||
and ifnull(show_in_website,0)=1""", self.doc.name, as_dict=1)
|
@ -4,7 +4,7 @@
|
||||
"docstatus": 0,
|
||||
"creation": "2012-12-07 15:15:28",
|
||||
"modified_by": "Administrator",
|
||||
"modified": "2012-12-18 16:23:48"
|
||||
"modified": "2012-12-20 16:11:15"
|
||||
},
|
||||
{
|
||||
"in_create": 1,
|
||||
@ -103,29 +103,13 @@
|
||||
"fieldtype": "Check"
|
||||
},
|
||||
{
|
||||
"description": "HTML / Banner that will show on the top of product list.",
|
||||
"depends_on": "show_in_website",
|
||||
"doctype": "DocField",
|
||||
"label": "Description",
|
||||
"fieldname": "description",
|
||||
"fieldtype": "Text Editor"
|
||||
},
|
||||
{
|
||||
"depends_on": "show_in_website",
|
||||
"doctype": "DocField",
|
||||
"label": "Featured Items",
|
||||
"fieldname": "featured_items_html",
|
||||
"fieldtype": "Section Break"
|
||||
},
|
||||
{
|
||||
"description": "Items Featured on the Item Group Page",
|
||||
"depends_on": "show_in_website",
|
||||
"doctype": "DocField",
|
||||
"label": "Featured Items",
|
||||
"fieldname": "featured_items",
|
||||
"fieldtype": "Table",
|
||||
"hidden": 0,
|
||||
"options": "Featured Item"
|
||||
},
|
||||
{
|
||||
"print_hide": 1,
|
||||
"no_copy": 1,
|
||||
@ -168,13 +152,6 @@
|
||||
"options": "Item Group",
|
||||
"report_hide": 1
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"label": "file_list",
|
||||
"fieldname": "file_list",
|
||||
"fieldtype": "Text",
|
||||
"hidden": 1
|
||||
},
|
||||
{
|
||||
"print_hide": 1,
|
||||
"no_copy": 1,
|
||||
|
@ -4,7 +4,7 @@
|
||||
"docstatus": 0,
|
||||
"creation": "2012-12-17 14:56:32",
|
||||
"modified_by": "Administrator",
|
||||
"modified": "2012-12-18 14:23:19"
|
||||
"modified": "2012-12-20 15:59:41"
|
||||
},
|
||||
{
|
||||
"allow_attach": 1,
|
||||
@ -771,6 +771,15 @@
|
||||
"fieldtype": "Data",
|
||||
"permlevel": 1
|
||||
},
|
||||
{
|
||||
"description": "Products will be sorted by weight-age in default searches. More the weight-age, higher the product will appear in the list.",
|
||||
"search_index": 1,
|
||||
"doctype": "DocField",
|
||||
"label": "Weightage",
|
||||
"fieldname": "weightage",
|
||||
"fieldtype": "Int",
|
||||
"permlevel": 0
|
||||
},
|
||||
{
|
||||
"depends_on": "show_in_website",
|
||||
"doctype": "DocField",
|
||||
@ -823,18 +832,9 @@
|
||||
"permlevel": 0
|
||||
},
|
||||
{
|
||||
"description": "Will appear in search",
|
||||
"depends_on": "show_in_website",
|
||||
"doctype": "DocField",
|
||||
"label": "Short Description",
|
||||
"fieldname": "web_short_description",
|
||||
"fieldtype": "Text Editor",
|
||||
"permlevel": 0
|
||||
},
|
||||
{
|
||||
"depends_on": "show_in_website",
|
||||
"doctype": "DocField",
|
||||
"label": "Long Description",
|
||||
"label": "Website Description",
|
||||
"fieldname": "web_long_description",
|
||||
"fieldtype": "Text Editor",
|
||||
"permlevel": 0
|
||||
|
0
website/doctype/product_settings/__init__.py
Normal file
0
website/doctype/product_settings/__init__.py
Normal file
8
website/doctype/product_settings/product_settings.py
Normal file
8
website/doctype/product_settings/product_settings.py
Normal file
@ -0,0 +1,8 @@
|
||||
# For license information, please see license.txt
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import webnotes
|
||||
|
||||
class DocType:
|
||||
def __init__(self, d, dl):
|
||||
self.doc, self.doclist = d, dl
|
65
website/doctype/product_settings/product_settings.txt
Normal file
65
website/doctype/product_settings/product_settings.txt
Normal file
@ -0,0 +1,65 @@
|
||||
[
|
||||
{
|
||||
"owner": "Administrator",
|
||||
"docstatus": 0,
|
||||
"creation": "2012-12-20 14:05:00",
|
||||
"modified_by": "Administrator",
|
||||
"modified": "2012-12-20 15:46:15"
|
||||
},
|
||||
{
|
||||
"issingle": 1,
|
||||
"description": "Settings for Product Catalog on the website",
|
||||
"doctype": "DocType",
|
||||
"module": "Website",
|
||||
"document_type": "Other",
|
||||
"name": "__common__"
|
||||
},
|
||||
{
|
||||
"name": "__common__",
|
||||
"parent": "Product Settings",
|
||||
"doctype": "DocField",
|
||||
"parenttype": "DocType",
|
||||
"permlevel": 0,
|
||||
"parentfield": "fields"
|
||||
},
|
||||
{
|
||||
"parent": "Product Settings",
|
||||
"read": 1,
|
||||
"name": "__common__",
|
||||
"create": 1,
|
||||
"doctype": "DocPerm",
|
||||
"write": 1,
|
||||
"parenttype": "DocType",
|
||||
"role": "Website Manager",
|
||||
"permlevel": 0,
|
||||
"parentfield": "permissions"
|
||||
},
|
||||
{
|
||||
"name": "Product Settings",
|
||||
"doctype": "DocType"
|
||||
},
|
||||
{
|
||||
"description": "Default: \"Product Search\"",
|
||||
"doctype": "DocField",
|
||||
"label": "Search Help",
|
||||
"fieldname": "search_help",
|
||||
"fieldtype": "Data"
|
||||
},
|
||||
{
|
||||
"description": "List of Item Groups to be shown in \"All Products\" menu - in the sequence wanted and with number of indents (left spacing to show a tree effect).",
|
||||
"doctype": "DocField",
|
||||
"label": "Product Categories",
|
||||
"fieldname": "sb2",
|
||||
"fieldtype": "Section Break"
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"label": "Website Product Categories",
|
||||
"fieldname": "website_product_categories",
|
||||
"fieldtype": "Table",
|
||||
"options": "Website Product Category"
|
||||
},
|
||||
{
|
||||
"doctype": "DocPerm"
|
||||
}
|
||||
]
|
@ -0,0 +1,8 @@
|
||||
# For license information, please see license.txt
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import webnotes
|
||||
|
||||
class DocType:
|
||||
def __init__(self, d, dl):
|
||||
self.doc, self.doclist = d, dl
|
@ -0,0 +1,43 @@
|
||||
[
|
||||
{
|
||||
"owner": "Administrator",
|
||||
"docstatus": 0,
|
||||
"creation": "2012-12-20 14:21:35",
|
||||
"modified_by": "Administrator",
|
||||
"modified": "2012-12-20 15:00:25"
|
||||
},
|
||||
{
|
||||
"istable": 1,
|
||||
"description": "Product Category for website",
|
||||
"doctype": "DocType",
|
||||
"module": "Website",
|
||||
"document_type": "Transaction",
|
||||
"name": "__common__"
|
||||
},
|
||||
{
|
||||
"name": "__common__",
|
||||
"parent": "Website Product Category",
|
||||
"doctype": "DocField",
|
||||
"parenttype": "DocType",
|
||||
"permlevel": 0,
|
||||
"parentfield": "fields"
|
||||
},
|
||||
{
|
||||
"name": "Website Product Category",
|
||||
"doctype": "DocType"
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"label": "Item Group",
|
||||
"fieldname": "item_group",
|
||||
"fieldtype": "Link",
|
||||
"options": "Item Group"
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"label": "Indent",
|
||||
"fieldname": "indent",
|
||||
"fieldtype": "Select",
|
||||
"options": "0\n1\n2\n3\n4\n5"
|
||||
}
|
||||
]
|
@ -4,7 +4,7 @@
|
||||
"docstatus": 0,
|
||||
"creation": "2012-07-12 23:29:36",
|
||||
"modified_by": "Administrator",
|
||||
"modified": "2012-12-18 16:15:43"
|
||||
"modified": "2012-12-20 14:28:46"
|
||||
},
|
||||
{
|
||||
"issingle": 1,
|
||||
@ -65,15 +65,6 @@
|
||||
"fieldtype": "Column Break",
|
||||
"permlevel": 0
|
||||
},
|
||||
{
|
||||
"description": "Only Items / Groups under this Groups will be shown on the website. This will also represent the \"Products\" Home Page.",
|
||||
"doctype": "DocField",
|
||||
"label": "Default Product Category",
|
||||
"options": "Item Group",
|
||||
"fieldname": "default_product_category",
|
||||
"fieldtype": "Link",
|
||||
"permlevel": 0
|
||||
},
|
||||
{
|
||||
"description": "If checked, the Home page will be the default Item Group for the website.",
|
||||
"doctype": "DocField",
|
||||
|
@ -4,6 +4,7 @@
|
||||
from __future__ import unicode_literals
|
||||
import webnotes
|
||||
|
||||
|
||||
@webnotes.whitelist(allow_guest=True)
|
||||
def get_product_info(item_code):
|
||||
"""get product price / stock info"""
|
||||
@ -24,40 +25,37 @@ def get_product_info(item_code):
|
||||
}
|
||||
|
||||
@webnotes.whitelist(allow_guest=True)
|
||||
def get_product_list(args=None):
|
||||
def get_product_list(search=None, product_group=None, start=0):
|
||||
import webnotes
|
||||
from webnotes.utils import cstr
|
||||
|
||||
if not args: args = webnotes.form_dict
|
||||
if not args.search: args.search = ""
|
||||
|
||||
|
||||
# base query
|
||||
query = """\
|
||||
select name, item_name, page_name, website_image, item_group,
|
||||
if(ifnull(web_short_description,'')='', web_long_description,
|
||||
web_short_description) as web_short_description
|
||||
web_long_description as website_description
|
||||
from `tabItem`
|
||||
where docstatus = 0
|
||||
and show_in_website = 1 """
|
||||
|
||||
# search term condition
|
||||
if args.search:
|
||||
if 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
|
||||
)"""
|
||||
args['search'] = "%" + cstr(args.get('search')) + "%"
|
||||
search = "%" + cstr(search) + "%"
|
||||
|
||||
# product group condition
|
||||
if args.get('product_group') and args.get('product_group') != 'All Products':
|
||||
if product_group:
|
||||
query += """
|
||||
and item_group = %(product_group)s """
|
||||
|
||||
# order by
|
||||
query += """order by item_name asc, name asc limit %s, 10""" % args.start
|
||||
query += """order by item_name asc, name asc limit %s, 10""" % start
|
||||
|
||||
return webnotes.conn.sql(query, args, as_dict=1)
|
||||
return webnotes.conn.sql(query, {
|
||||
"search": search,
|
||||
"product_group": product_group
|
||||
}, as_dict=1)
|
@ -9,11 +9,14 @@
|
||||
<p class="help">Weblog (blog) entry</p>
|
||||
</div>
|
||||
<div style="width: 48%; float: right;">
|
||||
<h5><a href="#Form/Website Settings/Website Settings">Website Settings</a></h5>
|
||||
<h5><a href="#Form/Website Settings">Website Settings</a></h5>
|
||||
<p class="help">Setup of top navigation bar, footer and logo</p>
|
||||
<br>
|
||||
<h5><a href="#Form/Style Settings/Style Settings">Style Settings</a></h5>
|
||||
<h5><a href="#Form/Style Settings">Style Settings</a></h5>
|
||||
<p class="help">Setup of fonts and background</p>
|
||||
<br>
|
||||
<h5><a href="#Form/Product Settings">Product Settings</a></h5>
|
||||
<p class="help">Settings for Product Catalog on the website.</p>
|
||||
</div>
|
||||
<div style="clear: both"></div>
|
||||
<hr>
|
||||
|
@ -23,6 +23,9 @@
|
||||
.login-box td {
|
||||
padding: 8px;
|
||||
}
|
||||
.login-box td input {
|
||||
margin-bottom: 0px;
|
||||
}
|
||||
.login-footer {
|
||||
text-align: center;
|
||||
padding: 15px;
|
||||
|
@ -35,7 +35,11 @@
|
||||
<ul class="dropdown-menu">
|
||||
{% for child in page.child_items %}
|
||||
<li data-label="{{ child.label }}">
|
||||
<a href="{{ child.url }}" {{ child.target or '' }}>
|
||||
<a {% if child.indent %}
|
||||
style="padding-left:
|
||||
{{(int(child.indent)+1)*15 }}px"
|
||||
{% endif %}
|
||||
href="{{ child.url }}" {{ child.target or '' }}>
|
||||
{{ child.label }}
|
||||
</a>
|
||||
</li>
|
||||
|
@ -1,7 +1,19 @@
|
||||
{% extends "html/page.html" %}
|
||||
|
||||
{% block javascript %}
|
||||
{% include "js/product_list.js" %}
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
window.start = 0;
|
||||
window.product_group = "{{ name }}";
|
||||
window.get_product_list();
|
||||
});
|
||||
</script>
|
||||
|
||||
<div class="layout-wrapper layout-wrapper-background">
|
||||
<div class="web-content" id="content-product_group">
|
||||
<div class="layout-main" style="padding: 30px;">
|
||||
@ -22,12 +34,17 @@
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% if obj.doclist.get({"doctype":"Featured Item"}) %}
|
||||
<hr>
|
||||
<h3>Featured Products</h3>
|
||||
|
||||
{% endif %}
|
||||
|
||||
<h3>Products</h3>
|
||||
<div id="search-list">
|
||||
|
||||
</div>
|
||||
<div style="text-align: center;">
|
||||
<div class="more-btn"
|
||||
style="display: none; text-align: center;">
|
||||
<button class="btn">More...</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -10,6 +10,7 @@
|
||||
<script>
|
||||
// redirect to product search page
|
||||
$(document).ready(function() {
|
||||
$('.dropdown-toggle').dropdown()
|
||||
$("#btn-product-search").click(function() {
|
||||
var txt = $("#product-search").val();
|
||||
if(txt) {
|
||||
|
69
website/templates/js/product_list.js
Normal file
69
website/templates/js/product_list.js
Normal file
@ -0,0 +1,69 @@
|
||||
window.get_product_list = function() {
|
||||
$(".more-btn .btn").click(function() {
|
||||
window.get_product_list()
|
||||
});
|
||||
|
||||
if(window.start==undefined) {
|
||||
throw "product list not initialized (no start)"
|
||||
}
|
||||
|
||||
$.ajax({
|
||||
method: "GET",
|
||||
url: "server.py",
|
||||
dataType: "json",
|
||||
data: {
|
||||
cmd: "website.helpers.product.get_product_list",
|
||||
start: window.start,
|
||||
search: window.search,
|
||||
product_group: window.product_group
|
||||
},
|
||||
dataType: "json",
|
||||
success: function(data) {
|
||||
window.render_product_list(data.message);
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
window.render_product_list = function(data) {
|
||||
if(data.length) {
|
||||
var table = $("#search-list .table");
|
||||
if(!table.length)
|
||||
var table = $("<table class='table'>").appendTo("#search-list");
|
||||
|
||||
$.each(data, function(i, d) {
|
||||
if(!d.web_short_description)
|
||||
d.web_short_description = "No description given."
|
||||
var $tr = $(repl('<tr>\
|
||||
<td style="width: 30%;">\
|
||||
<img class="product-image" \
|
||||
style="width: 80%;" src="files/%(website_image)s">\
|
||||
</td>\
|
||||
<td>\
|
||||
<h4><a href="%(page_name)s">%(item_name)s</a></h4>\
|
||||
<p class="help">Item Code: %(name)s</p>\
|
||||
<p>%(website_description)s</p>\
|
||||
</td>\
|
||||
</tr>', d)).appendTo(table);
|
||||
|
||||
if(!d.website_image) {
|
||||
$tr.find(".product-image").replaceWith("<div\
|
||||
style='background-color: #eee; padding: 40px; \
|
||||
width: 32px; font-size: 32px; color: #888;'>\
|
||||
<i class='icon-camera'></i></div>");
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
if(data.length < 10) {
|
||||
if(!table) {
|
||||
$(".more-btn")
|
||||
.replaceWith("<div class='alert'>No products found.</div>");
|
||||
} else {
|
||||
$(".more-btn")
|
||||
.replaceWith("<div class='alert'>Nothing more to show.</div>");
|
||||
}
|
||||
} else {
|
||||
$(".more-btn").toggle(true)
|
||||
}
|
||||
window.start += (data.length || 0);
|
||||
}
|
@ -2,77 +2,18 @@
|
||||
|
||||
{% block title %}Product Search{% endblock %}
|
||||
|
||||
{% block javascript %}
|
||||
{% include "js/product_list.js" %}
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
var txt = get_url_arg("q");
|
||||
$(".search-results").html("Search results for: " + txt);
|
||||
|
||||
window.search = txt;
|
||||
window.start = 0;
|
||||
var get_list = function() {
|
||||
$.ajax({
|
||||
method: "GET",
|
||||
url: "server.py",
|
||||
dataType: "json",
|
||||
data: {
|
||||
cmd: "website.helpers.product.get_product_list",
|
||||
start: window.start,
|
||||
search: txt
|
||||
},
|
||||
dataType: "json",
|
||||
success: function(data) {
|
||||
render(data.message);
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
var render = function(data) {
|
||||
if(data.length) {
|
||||
var table = $("#search-list .table");
|
||||
if(!table.length)
|
||||
var table = $("<table class='table'>").appendTo("#search-list");
|
||||
|
||||
$.each(data, function(i, d) {
|
||||
if(!d.web_short_description)
|
||||
d.web_short_description = "No description given."
|
||||
var $tr = $(repl('<tr>\
|
||||
<td style="width: 30%;">\
|
||||
<img class="product-image" style="width: 80%;" src="files/%(website_image)s">\
|
||||
</td>\
|
||||
<td>\
|
||||
<h4><a href="%(page_name)s">%(item_name)s</a></h4>\
|
||||
<p class="help">Item Code: %(name)s</p>\
|
||||
<p>%(web_short_description)s</p>\
|
||||
</td>\
|
||||
</tr>', d)).appendTo(table);
|
||||
|
||||
if(!d.website_image) {
|
||||
$tr.find(".product-image").replaceWith("<div\
|
||||
style='background-color: #eee; padding: 40px; \
|
||||
width: 32px; font-size: 32px; color: #888;'>\
|
||||
<i class='icon-camera'></i></div>");
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
if(data.length < 10) {
|
||||
if(!table) {
|
||||
$(".more-btn")
|
||||
.replaceWith("<div class='alert'>No results found for your search.</div>");
|
||||
} else {
|
||||
$(".more-btn")
|
||||
.replaceWith("<div class='alert'>Nothing more to show.</div>");
|
||||
}
|
||||
} else {
|
||||
$(".more-btn").toggle(true)
|
||||
}
|
||||
window.start += (data.length || 0);
|
||||
}
|
||||
|
||||
get_list();
|
||||
$(".more-btn .btn").click(function() {
|
||||
get_list()
|
||||
});
|
||||
window.get_product_list();
|
||||
});
|
||||
</script>
|
||||
|
||||
|
@ -169,6 +169,7 @@ def get_doc_fields(page_name):
|
||||
args = obj.doc.fields
|
||||
args['template'] = page_map[doc_type].template
|
||||
args['obj'] = obj
|
||||
args['int'] = int
|
||||
|
||||
return args
|
||||
|
||||
@ -201,9 +202,19 @@ def get_outer_env():
|
||||
t['child_items'].append(d)
|
||||
break
|
||||
|
||||
if "products" in [d.url.split(".")[0] for d in top_items]:
|
||||
# product categories
|
||||
products = webnotes.conn.sql("""select t1.item_group as label,
|
||||
concat(t2.page_name, ".html") as url,
|
||||
ifnull(t1.indent,0) as indent
|
||||
from `tabWebsite Product Category` t1, `tabItem Group` t2
|
||||
where t1.item_group = t2.name
|
||||
and ifnull(t2.show_in_website,0)=1 order by t1.idx""", as_dict=1)
|
||||
products_item = filter(lambda d: d.url.split(".")[0]=="products", top_items)[0]
|
||||
products_item.child_items = products
|
||||
|
||||
return {
|
||||
'top_bar_items': top_items,
|
||||
|
||||
'footer_items': webnotes.conn.sql("""\
|
||||
select * from `tabTop Bar Item`
|
||||
where parent='Website Settings' and parentfield='footer_items'
|
||||
@ -211,7 +222,8 @@ def get_outer_env():
|
||||
|
||||
'brand': webnotes.conn.get_value('Website Settings', None, 'brand_html') or 'ERPNext',
|
||||
'copyright': webnotes.conn.get_value('Website Settings', None, 'copyright'),
|
||||
'favicon': webnotes.conn.get_value('Website Settings', None, 'favicon')
|
||||
'favicon': webnotes.conn.get_value('Website Settings', None, 'favicon'),
|
||||
'int':int
|
||||
}
|
||||
|
||||
def get_home_page():
|
||||
|
Loading…
x
Reference in New Issue
Block a user