Item, Item Group and Partner Web Page generators moved from Shopping Cart to ERPNext
diff --git a/erpnext/templates/generators/__init__.py b/erpnext/templates/generators/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/erpnext/templates/generators/__init__.py
diff --git a/erpnext/templates/generators/item.html b/erpnext/templates/generators/item.html
new file mode 100644
index 0000000..4d4f5d4
--- /dev/null
+++ b/erpnext/templates/generators/item.html
@@ -0,0 +1,84 @@
+{% block title %} {{ title }} {% endblock %}
+
+{% block header %}<h2>{{ title }}</h2>{% endblock %}
+
+{% block content %}
+<div class="item-content">
+	{% include 'templates/includes/product_search_box.html' %}
+	{% include 'templates/includes/product_breadcrumbs.html' %}
+	<div class="product-page-content" itemscope itemtype="http://schema.org/Product">
+		<div class="row">
+			<div class="col-md-6">
+				{% if slideshow %}
+					{% include "templates/includes/slideshow.html" %}
+				{% else %}
+					{% if website_image %}
+					<image itemprop="image" class="item-main-image"
+						src="{{ website_image }}" />
+					{% else %}
+					<div class="img-area">
+		{% include 'templates/includes/product_missing_image.html' %}
+					</div>
+					{% endif %}
+				{% endif %}
+			</div>
+			<div class="col-md-6">
+				<h3 itemprop="name" style="margin-top: 0px;">{{ item_name }}</h3>
+				<p class="help">Item Code: <span itemprop="productID">{{ name }}</span></p>
+				<h4>Product Description</h4>
+				<div itemprop="description">
+				{{ web_long_description or description or "[No description given]" }}
+				</div>
+				<div style="min-height: 100px; margin: 10px 0;">
+					<div class="item-price-info" style="display: none;">
+						<h4 class="item-price" itemprop="price"></h4>
+						<div class="item-stock" itemprop="availablity"></div>
+						<div id="item-add-to-cart">
+							<button class="btn btn-primary">
+								<i class="icon-shopping-cart"></i> Add to Cart</button>
+						</div>
+						<div id="item-update-cart" class="input-group col-md-4" style="display: none;
+							padding-left: 0px; padding-right: 0px;">
+							<input class="form-control" type="text">
+							<div class="input-group-btn">
+								<button class="btn btn-primary">
+									<i class="icon-ok"></i></button>
+							</div>
+						</div>
+					</div>
+				</div>
+			</div>
+		</div>
+		{% if doc.get({"doctype":"Item Website Specification"}) -%}
+		<div class="row" style="margin-top: 20px">
+			<div class="col-md-12">
+				<h4>Specifications</h4>
+				<table class="table table-bordered" style="width: 100%">
+				{% for d in doc.get(
+					{"doctype":"Item Website Specification"}) -%}
+					<tr>
+						<td style="width: 30%;">{{ d.label }}</td>
+						<td>{{ d.description }}</td>
+					</tr>
+				{%- endfor %}
+				</table>
+			</div>
+		</div>
+		{%- endif %}
+	</div>
+</div>
+<script>
+	{% include "templates/includes/product_page.js" %}
+
+	$(function() {
+		if(window.logged_in && getCookie("system_user")==="yes") {
+			frappe.has_permission("Item", "{{ name }}", "write", function(r) {
+				frappe.require("/assets/frappe/js/frappe/website/editable.js");
+				frappe.make_editable($('[itemprop="description"]'), "Item", "{{ name }}", "web_long_description");
+			});
+		}
+	});
+</script>
+{% endblock %}
+
+{% block sidebar %}{% include "templates/includes/sidebar.html" %}{% endblock %}
diff --git a/erpnext/templates/generators/item.py b/erpnext/templates/generators/item.py
new file mode 100644
index 0000000..1ad070e
--- /dev/null
+++ b/erpnext/templates/generators/item.py
@@ -0,0 +1,20 @@
+# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
+# License: GNU General Public License v3. See license.txt
+
+from __future__ import unicode_literals
+
+import frappe
+from erpnext.setup.doctype.item_group.item_group import get_parent_item_groups
+from frappe.website.doctype.website_slideshow.website_slideshow import get_slideshow
+
+doctype = "Item"
+condition_field = "show_in_website"
+
+def get_context(context):
+	item_context = context.doc.as_dict()
+	item_context["parent_groups"] = get_parent_item_groups(context.doc.item_group) + \
+		[{"name":context.doc.name}]
+	if context.doc.slideshow:
+		item_context.update(get_slideshow(context.doc))
+
+	return item_context
diff --git a/erpnext/templates/generators/item_group.html b/erpnext/templates/generators/item_group.html
new file mode 100644
index 0000000..ae0cd22
--- /dev/null
+++ b/erpnext/templates/generators/item_group.html
@@ -0,0 +1,58 @@
+{% block title %} {{ title }} {% endblock %}
+
+{% block header %}<h2>{{ title }}</h2>{% endblock %}
+
+{% block content %}
+<div class="item-group-content">
+	{% include 'templates/includes/product_search_box.html' %}
+	{% include 'templates/includes/product_breadcrumbs.html' %}
+	<div>
+		{% if slideshow %}<!-- slideshow -->
+		{% include "templates/includes/slideshow.html" %}
+		{% endif %}
+		{% if description %}<!-- description -->
+		<div itemprop="description">{{ description or ""}}</div>
+		{% else %}
+		<h3>{{ name }}</h3>
+		{% endif %}
+	</div>
+	<div>
+		{% if sub_groups %}
+		<hr />
+		<div class="row">
+		{% for d in sub_groups %}
+			<div class="col-sm-4">
+				<a href="{{ d.page_name }}">{{ d.name }} ({{ d.count }})</a>
+			</div>
+		{% endfor %}
+		</div>
+		<hr />
+		{% endif %}
+		{% if items %}
+		<div id="search-list" class="row">
+			{% for item in items %}
+				{{ item }}
+			{% endfor %}
+		</div>
+			{% if (items|length)==100 %}
+				<div class="alert alert-info info">Showing top 100 items.</div>
+			{% endif %}
+		{% else %}
+			<div class="alert alert-warning">No items listed.</div>
+		{% endif %}
+	</div>	
+</div>
+<script>
+$(function() {
+	if(window.logged_in && getCookie("system_user")==="yes") {
+		frappe.has_permission("Item Group", "{{ name }}", "write", function(r) {
+			frappe.require("/assets/frappe/js/frappe/website/editable.js");
+			frappe.make_editable($('[itemprop="description"]'), "Item Group", "{{ name }}", "description");
+		});
+	}
+});
+</script>
+
+{% endblock %}
+
+{% block sidebar %}{% include "templates/includes/sidebar.html" %}{% endblock %}
\ No newline at end of file
diff --git a/erpnext/templates/generators/item_group.py b/erpnext/templates/generators/item_group.py
new file mode 100644
index 0000000..7743018
--- /dev/null
+++ b/erpnext/templates/generators/item_group.py
@@ -0,0 +1,64 @@
+# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
+# License: GNU General Public License v3. See license.txt
+
+from __future__ import unicode_literals
+
+import frappe
+from frappe.website.doctype.website_slideshow.website_slideshow import get_slideshow
+from erpnext.setup.doctype.item_group.item_group import get_parent_item_groups
+
+doctype = "Item Group"
+condition_field = "show_in_website"
+
+def get_context(context):
+	item_group_context = context.doc.as_dict()
+	item_group_context.update({
+		"sub_groups": frappe.db.sql("""select name, page_name
+			from `tabItem Group` where parent_item_group=%s
+			and ifnull(show_in_website,0)=1""", context.docname, as_dict=1),
+		"items": get_product_list_for_group(product_group = context.docname, limit=100),
+		"parent_groups": get_parent_item_groups(context.docname),
+		"title": context.docname
+	})
+
+	if context.doc.slideshow:
+		item_group_context.update(get_slideshow(context.doc))
+
+	for d in item_group_context.sub_groups:
+		d.count = get_group_item_count(d.name)
+
+	return item_group_context
+
+def get_product_list_for_group(product_group=None, start=0, limit=10):
+	child_groups = ", ".join(['"' + i[0] + '"' for i in get_child_groups(product_group)])
+
+	# base query
+	query = """select name, item_name, page_name, website_image, item_group,
+			web_long_description as website_description
+		from `tabItem` where docstatus = 0 and show_in_website = 1
+		and (item_group in (%s)
+			or name in (select parent from `tabWebsite Item Group` where item_group in (%s))) """ % (child_groups, child_groups)
+
+	query += """order by weightage desc, modified desc limit %s, %s""" % (start, limit)
+
+	data = frappe.db.sql(query, {"product_group": product_group}, as_dict=1)
+
+	return [get_item_for_list_in_html(r) for r in data]
+
+def get_child_groups(item_group_name):
+	item_group = frappe.get_doc("Item Group", item_group_name)
+	return frappe.db.sql("""select name
+		from `tabItem Group` where lft>=%(lft)s and rgt<=%(rgt)s
+			and show_in_website = 1""", item_group.as_dict())
+
+def get_item_for_list_in_html(context):
+	return frappe.get_template("templates/includes/product_in_grid.html").render(context)
+
+def get_group_item_count(item_group):
+	child_groups = ", ".join(['"' + i[0] + '"' for i in get_child_groups(item_group)])
+	return frappe.db.sql("""select count(*) from `tabItem`
+		where docstatus = 0 and show_in_website = 1
+		and (item_group in (%s)
+			or name in (select parent from `tabWebsite Item Group`
+				where item_group in (%s))) """ % (child_groups, child_groups))[0][0]
+
diff --git a/erpnext/templates/generators/partner.html b/erpnext/templates/generators/partner.html
new file mode 100644
index 0000000..6a869a1
--- /dev/null
+++ b/erpnext/templates/generators/partner.html
@@ -0,0 +1,29 @@
+{% block title %} {{ title }} {% endblock %}
+
+{% block header %}<h2>{{ title }}</h2>{% endblock %}
+
+{% block content %}
+<div class="partner-content" itemscope itemtype="http://schema.org/Organization">
+	<div class="row">
+		<div class="col-md-4">
+			{% if logo -%}
+			<img itemprop="brand" src="{{ logo }}" class="partner-logo" 
+				alt="{{ partner_name }}" title="{{ partner_name }}" />
+			<br><br>
+			{%- endif %}
+			<address>
+				{% if partner_website -%}<p><a href="{{ partner_website }}" 
+					target="_blank">{{ partner_website }}</a></p>{%- endif %}
+				{% if partner_address -%}<p itemprop="address">{{ partner_address }}</p>{%- endif %}
+				{% if phone -%}<p itemprop="telephone">{{ phone }}</p>{%- endif %}
+				{% if email -%}<p itemprop="email"><span class="icon-envelope"></span> {{ email }}</p>{%- endif %}
+			</address>
+		</div>
+		<div class="col-md-8">
+			<p>{{ description }}</p>
+		</div>
+	</div>
+</div>
+{% endblock %}
+
+{% block sidebar %}{% include "templates/includes/sidebar.html" %}{% endblock %}
\ No newline at end of file
diff --git a/erpnext/templates/generators/partner.py b/erpnext/templates/generators/partner.py
new file mode 100644
index 0000000..2079309
--- /dev/null
+++ b/erpnext/templates/generators/partner.py
@@ -0,0 +1,28 @@
+# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
+# License: GNU General Public License v3. See license.txt
+
+from __future__ import unicode_literals
+import frappe
+from frappe.utils import filter_strip_join
+
+doctype = "Sales Partner"
+condition_field = "show_in_website"
+
+def get_context(context):
+	partner_context = context.doc.as_dict()
+	
+	address = frappe.db.get_value("Address", 
+		{"sales_partner": context.doc.name, "is_primary_address": 1}, 
+		"*", as_dict=True)
+	if address:
+		city_state = ", ".join(filter(None, [address.city, address.state]))
+		address_rows = [address.address_line1, address.address_line2,
+			city_state, address.pincode, address.country]
+			
+		partner_context.update({
+			"email": address.email_id,
+			"partner_address": filter_strip_join(address_rows, "\n<br>"),
+			"phone": filter_strip_join(cstr(address.phone).split(","), "\n<br>")
+		})
+	
+	return partner_context