Merge branch 'shf_rename' of github.com:webnotes/erpnext into shf_rename

This commit is contained in:
Anand Doshi 2012-04-30 15:44:02 +05:30
commit 72308564be
28 changed files with 346 additions and 719 deletions

View File

@ -1944,6 +1944,24 @@ h1, h2, h3, h4, h5 {
body {
font-family: "Helvetica Neue", Helvetica, "Helvetica Neue", sans-serif;
font-size: 13px;
background-color: #eee;
}
footer {
background: #b7b7b7; /* Old browsers */
background: -moz-linear-gradient(top, #b7b7b7 0%, #eeeeee 36%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#b7b7b7), color-stop(36%,#eeeeee)); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, #b7b7b7 0%,#eeeeee 36%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, #b7b7b7 0%,#eeeeee 36%); /* Opera 11.10+ */
background: -ms-linear-gradient(top, #b7b7b7 0%,#eeeeee 36%); /* IE10+ */
background: linear-gradient(top, #b7b7b7 0%,#eeeeee 36%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#b7b7b7', endColorstr='#eeeeee',GradientType=0 ); /* IE6-9 */
border-top: 1px solid #999;
text-align: center;
color: inherit;
padding: 10px;
font-size: 12px;
line-height: 1.7;
}
span, div, td, input, textarea, button, select {
@ -2049,10 +2067,10 @@ div.comment { color: #444; }
}
div#body_div {
display: none;
padding-right: 7px;
padding-top: 70px;
padding-bottom: 50px;
min-height: 400px;
}
.content {

View File

@ -1805,6 +1805,24 @@ h1, h2, h3, h4, h5 {
body {
font-family: "Helvetica Neue", Helvetica, "Helvetica Neue", sans-serif;
font-size: 13px;
background-color: #eee;
}
footer {
background: #b7b7b7; /* Old browsers */
background: -moz-linear-gradient(top, #b7b7b7 0%, #eeeeee 36%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#b7b7b7), color-stop(36%,#eeeeee)); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, #b7b7b7 0%,#eeeeee 36%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, #b7b7b7 0%,#eeeeee 36%); /* Opera 11.10+ */
background: -ms-linear-gradient(top, #b7b7b7 0%,#eeeeee 36%); /* IE10+ */
background: linear-gradient(top, #b7b7b7 0%,#eeeeee 36%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#b7b7b7', endColorstr='#eeeeee',GradientType=0 ); /* IE6-9 */
border-top: 1px solid #999;
text-align: center;
color: inherit;
padding: 10px;
font-size: 12px;
line-height: 1.7;
}
span, div, td, input, textarea, button, select {
@ -1910,10 +1928,10 @@ div.comment { color: #444; }
}
div#body_div {
display: none;
padding-right: 7px;
padding-top: 70px;
padding-bottom: 50px;
min-height: 400px;
}
.content {
@ -2597,21 +2615,7 @@ pre {
footer {
background-color: #eee;
box-shadow: inset 0 10px 10px rgba(0,0,0,0.3), inset 0 3px 3px rgba(0,0,0,0.3);
border-top: 1px solid #555;
padding-top: 10px;
text-align: center;
}
.web-footer {
color: inherit;
padding: 10px;
line-height: 1.7;
}
.web-footer div, .web-footer a {
font-size: 12px;
}
.web-footer-menu {

View File

@ -156,6 +156,9 @@ class DocType:
if self.doc.has_serial_no == 'Yes' and self.doc.is_stock_item == 'No':
msgprint("'Has Serial No' can not be 'Yes' for non-stock item", raise_exception=1)
# make product page
self.make_page()
def check_non_asset_warehouse(self):
if self.doc.is_asset_item == "Yes":
existing_qty = sql("select t1.warehouse, t1.actual_qty from tabBin t1, tabWarehouse t2 where t1.item_code=%s and (t2.warehouse_type!='Fixed Asset' or t2.warehouse_type is null) and t1.warehouse=t2.name and t1.actual_qty > 0", self.doc.name)
@ -208,3 +211,35 @@ Total Available Qty: %s
def on_rename(self,newdn,olddn):
sql("update tabItem set item_code = %s where name = %s", (newdn, olddn))
def make_page(self):
if self.doc.show_in_website=='Yes':
import website.utils
if self.doc.page_name:
import webnotes.model
webnotes.model.delete_doc('Page', self.doc.page_name)
p = website.utils.add_page("Product " + self.doc.item_name)
self.doc.page_name = p.name
from jinja2 import Template
import markdown2
import os
self.doc.long_description_html = markdown2.markdown(self.doc.description or '')
with open(os.path.join(os.path.dirname(__file__), 'template.html'), 'r') as f:
p.content = Template(f.read()).render(doc=self.doc)
with open(os.path.join(os.path.dirname(__file__), 'product_page.js'), 'r') as f:
p.script = Template(f.read()).render(doc=self.doc)
p.save()
website.utils.add_guest_access_to_page(p.name)
del self.doc.fields['long_description_html']

View File

@ -3,9 +3,9 @@
# These values are common in all dictionaries
{
'creation': '2012-03-27 14:36:31',
'creation': '2012-04-02 16:02:29',
'docstatus': 0,
'modified': '2012-03-27 18:51:27',
'modified': '2012-04-30 14:08:08',
'modified_by': u'Administrator',
'owner': u'Administrator'
},
@ -29,7 +29,7 @@
'show_in_menu': 0,
'subject': u'%(item_name)s',
'tag_fields': u'item_group',
'version': 172
'version': 1
},
# These values are common for all DocField
@ -57,6 +57,73 @@
'name': u'Item'
},
# DocPerm
{
'amend': 0,
'cancel': 0,
'create': 0,
'doctype': u'DocPerm',
'permlevel': 1,
'role': u'Material Manager',
'submit': 0,
'write': 0
},
# DocPerm
{
'amend': 0,
'cancel': 0,
'create': 0,
'doctype': u'DocPerm',
'permlevel': 0,
'role': u'Material Manager',
'submit': 0,
'write': 0
},
# DocPerm
{
'amend': 0,
'cancel': 0,
'create': 0,
'doctype': u'DocPerm',
'permlevel': 1,
'role': u'Material User',
'submit': 0,
'write': 0
},
# DocPerm
{
'amend': 0,
'cancel': 0,
'create': 0,
'doctype': u'DocPerm',
'permlevel': 0,
'role': u'Material User',
'submit': 0,
'write': 0
},
# DocPerm
{
'cancel': 1,
'create': 1,
'doctype': u'DocPerm',
'permlevel': 0,
'role': u'Material Master Manager',
'write': 1
},
# DocPerm
{
'create': 0,
'doctype': u'DocPerm',
'permlevel': 1,
'role': u'Material Master Manager',
'write': 0
},
# DocPerm
{
'cancel': 1,
@ -67,25 +134,6 @@
'write': 1
},
# DocPerm
{
'create': 0,
'doctype': u'DocPerm',
'permlevel': 1,
'role': u'Material Master Manager',
'write': 0
},
# DocPerm
{
'cancel': 1,
'create': 1,
'doctype': u'DocPerm',
'permlevel': 0,
'role': u'Material Master Manager',
'write': 1
},
# DocPerm
{
'doctype': u'DocPerm',
@ -93,54 +141,6 @@
'role': u'System Manager'
},
# DocPerm
{
'amend': 0,
'cancel': 0,
'create': 0,
'doctype': u'DocPerm',
'permlevel': 1,
'role': u'Material Manager',
'submit': 0,
'write': 0
},
# DocPerm
{
'amend': 0,
'cancel': 0,
'create': 0,
'doctype': u'DocPerm',
'permlevel': 0,
'role': u'Material Manager',
'submit': 0,
'write': 0
},
# DocPerm
{
'amend': 0,
'cancel': 0,
'create': 0,
'doctype': u'DocPerm',
'permlevel': 1,
'role': u'Material User',
'submit': 0,
'write': 0
},
# DocPerm
{
'amend': 0,
'cancel': 0,
'create': 0,
'doctype': u'DocPerm',
'permlevel': 0,
'role': u'Material User',
'submit': 0,
'write': 0
},
# DocField
{
'doctype': u'DocField',
@ -722,6 +722,26 @@
'reqd': 1
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'show_in_website',
'fieldtype': u'Select',
'label': u'Show in Website',
'options': u'No\nYes',
'permlevel': 0
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'website_image',
'fieldtype': u'Select',
'label': u'website_image',
'options': u'attach_files:',
'permlevel': 0
},
# DocField
{
'doctype': u'DocField',
@ -765,6 +785,17 @@
'permlevel': 0
},
# DocField
{
'colour': u'White:FFF',
'description': u'website page link',
'doctype': u'DocField',
'fieldname': u'page_name',
'fieldtype': u'Data',
'label': u'Page Name',
'permlevel': 1
},
# DocField
{
'doctype': u'DocField',

View File

@ -1,26 +1,19 @@
<div class="layout_wrapper">
<div class="layout-wrapper layout-wrapper-background">
<div class="web-content" id="content-product-{{ doc.name }}">
<h1>{{ doc.title }}</h1>
<div class="web-main-section">
<div class="layout-main-section">
<h1>{{ doc.item_name }}</h1>
<div style="float: left;">
<image src="files/{{ doc.full_image }}" style="width: 300px;
<br><br>
<image src="files/{{ doc.website_image }}" style="width: 300px;
margin-left: 15px;" />
<br><br>
{{ doc.long_description_html }}
<button class="btn primary product-inquiry"
data-product="{{ doc.name }}"
data-description="{{ doc.short_description }}">Send Inquiry</button>
</div>
</div>
<div class="web-side-section">
<div class="info-box round">
<p><b>Item Code:</b> {{ doc.item }}</p>
<p>{{ doc.short_description }}</p>
<p><button class="btn primary product-inquiry"
data-product="{{ doc.name }}"
data-description="{{ doc.short_description }}">Send Inquiry</button>
</p>
</div>
<br>
<div class="layout-side-section">
<h4>More Categories</h4>
<div class="more-categories"></div>
<br>

View File

@ -55,6 +55,7 @@ def get_active_users(arg=None):
@webnotes.whitelist()
def post(arg=None):
import webnotes
"""post message"""
if arg:
import json

View File

@ -65,21 +65,7 @@ pre {
footer {
background-color: #eee;
box-shadow: inset 0 10px 10px rgba(0,0,0,0.3), inset 0 3px 3px rgba(0,0,0,0.3);
border-top: 1px solid #555;
padding-top: 10px;
text-align: center;
}
.web-footer {
color: inherit;
padding: 10px;
line-height: 1.7;
}
.web-footer div, .web-footer a {
font-size: 12px;
}
.web-footer-menu {

View File

@ -33,6 +33,10 @@ class DocType():
def validate(self):
"""write/update 'Page' with the blog"""
# we need the name for the templates
if not self.doc.name:
self.autoname()
if self.doc.page_name:
webnotes.conn.sql("""delete from tabPage where name=%s""", self.doc.page_name)

View File

@ -1,22 +0,0 @@
// ERPNext - web based ERP (http://erpnext.com)
// Copyright (C) 2012 Web Notes Technologies Pvt Ltd
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
$.extend(cur_frm.cscript, {
onload: function() {
cur_frm.add_fetch('item', 'description', 'short_description');
cur_frm.add_fetch('item', 'item_name', 'title');
}
});

View File

@ -1,57 +0,0 @@
# ERPNext - web based ERP (http://erpnext.com)
# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import webnotes
class DocType:
def __init__(self, d, dl):
self.doc, self.doclist = d, dl
def validate(self):
"""make page for this product"""
import website.utils
p = website.utils.add_page("Product " + self.doc.title)
from jinja2 import Template
import markdown2
import os
self.doc.item_group = webnotes.conn.get_value('Item', self.doc.item, 'item_group')
self.doc.long_description_html = markdown2.markdown(self.doc.long_description or '')
with open(os.path.join(os.path.dirname(__file__), 'template.html'), 'r') as f:
p.content = Template(f.read()).render(doc=self.doc)
with open(os.path.join(os.path.dirname(__file__), 'product_page.js'), 'r') as f:
p.script = Template(f.read()).render(doc=self.doc)
p.save()
website.utils.add_guest_access_to_page(p.name)
self.doc.page_name = p.name
self.make_item_group_active()
del self.doc.fields['long_description_html']
del self.doc.fields['item_group']
def make_item_group_active(self):
"""show item group in website"""
if self.doc.published:
from webnotes.model.doc import Document
ig = Document('Item Group', self.doc.item_group)
ig.show_in_website = 1
ig.save()

View File

@ -1,266 +0,0 @@
# DocType, Product
[
# These values are common in all dictionaries
{
'creation': '2012-03-27 14:36:47',
'docstatus': 0,
'modified': '2012-03-27 14:36:47',
'modified_by': u'Administrator',
'owner': u'Administrator'
},
# These values are common for all DocType
{
'_last_update': u'1327997783',
'allow_attach': 1,
'autoname': u'field:item',
'colour': u'White:FFF',
'description': u'A Product is shown on the website and is linked to an item.',
'doctype': 'DocType',
'document_type': u'Master',
'max_attachments': 5,
'module': u'Website',
'name': '__common__',
'section_style': u'Simple',
'show_in_menu': 0,
'version': 12
},
# These values are common for all DocField
{
'doctype': u'DocField',
'name': '__common__',
'parent': u'Product',
'parentfield': u'fields',
'parenttype': u'DocType'
},
# These values are common for all DocPerm
{
'amend': 0,
'create': 1,
'doctype': u'DocPerm',
'name': '__common__',
'parent': u'Product',
'parentfield': u'permissions',
'parenttype': u'DocType',
'permlevel': 0,
'read': 1,
'submit': 0,
'write': 1
},
# DocType, Product
{
'doctype': 'DocType',
'name': u'Product'
},
# DocPerm
{
'cancel': 0,
'doctype': u'DocPerm',
'role': u'Sales Manager'
},
# DocPerm
{
'cancel': 0,
'doctype': u'DocPerm',
'role': u'Sales User'
},
# DocPerm
{
'cancel': 1,
'doctype': u'DocPerm',
'role': u'Website Manager'
},
# DocField
{
'colour': u'White:FFF',
'doctype': u'DocField',
'fieldname': u'item',
'fieldtype': u'Link',
'label': u'Item',
'options': u'Item',
'permlevel': 0,
'reqd': 1
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'title',
'fieldtype': u'Data',
'label': u'Title',
'permlevel': 0
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'published',
'fieldtype': u'Check',
'label': u'Published',
'permlevel': 0
},
# DocField
{
'colour': u'White:FFF',
'description': u'Select Price List for the web. Leave blank to hide price.',
'doctype': u'DocField',
'fieldname': u'price_list',
'fieldtype': u'Link',
'label': u'Price List',
'options': u'Price List',
'permlevel': 0
},
# DocField
{
'colour': u'White:FFF',
'description': u'Select shipping warehouse to show "In Stock" or "Out of Stock". To hide, leave blank',
'doctype': u'DocField',
'fieldname': u'warehouse',
'fieldtype': u'Link',
'label': u'Warehouse',
'options': u'Warehouse',
'permlevel': 0
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'column_break0',
'fieldtype': u'Column Break',
'permlevel': 0
},
# DocField
{
'colour': u'White:FFF',
'description': u'Image for listing (Width: 100px) (Attach First)',
'doctype': u'DocField',
'fieldname': u'thumbnail_image',
'fieldtype': u'Select',
'label': u'Thumbnail Image',
'options': u'attach_files:',
'permlevel': 0
},
# DocField
{
'colour': u'White:FFF',
'description': u'Image for listing (Width: 300px) (Attach First)',
'doctype': u'DocField',
'fieldname': u'full_image',
'fieldtype': u'Select',
'label': u'Full Image',
'options': u'attach_files:',
'permlevel': 0
},
# DocField
{
'colour': u'White:FFF',
'doctype': u'DocField',
'fieldname': u'short_description',
'fieldtype': u'Text',
'label': u'Short Description',
'permlevel': 0,
'reqd': 1
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'section_break0',
'fieldtype': u'Section Break',
'permlevel': 0
},
# DocField
{
'colour': u'White:FFF',
'description': u'Full description (formatted as markdown)',
'doctype': u'DocField',
'fieldname': u'long_description',
'fieldtype': u'Code',
'label': u'Long Description',
'permlevel': 0,
'reqd': 0
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'section_break1',
'fieldtype': u'Section Break',
'permlevel': 0
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'page_name',
'fieldtype': u'Data',
'label': u'Page Name',
'permlevel': 1
},
# DocField
{
'colour': u'White:FFF',
'doctype': u'DocField',
'fieldname': u'price',
'fieldtype': u'Currency',
'hidden': 0,
'label': u'Price',
'permlevel': 1
},
# DocField
{
'colour': u'White:FFF',
'doctype': u'DocField',
'fieldname': u'sales',
'fieldtype': u'Currency',
'label': u'Sales',
'permlevel': 1
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'stock',
'fieldtype': u'Currency',
'label': u'Stock',
'permlevel': 1
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'currency',
'fieldtype': u'Link',
'label': u'Currency',
'options': u'Currency',
'permlevel': 1
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'file_list',
'fieldtype': u'Text',
'hidden': 1,
'label': u'File List',
'no_copy': 1,
'permlevel': 0,
'print_hide': 1
}
]

View File

@ -1,57 +0,0 @@
# DocType, Product Group
[
# These values are common in all dictionaries
{
'creation': '2012-03-27 14:36:48',
'docstatus': 0,
'modified': '2012-03-27 14:36:48',
'modified_by': u'Administrator',
'owner': u'Administrator'
},
# These values are common for all DocType
{
'colour': u'White:FFF',
'doctype': 'DocType',
'istable': 1,
'module': u'Website',
'name': '__common__',
'section_style': u'Simple',
'show_in_menu': 0,
'version': 1
},
# These values are common for all DocField
{
'doctype': u'DocField',
'name': '__common__',
'parent': u'Product Group',
'parentfield': u'fields',
'parenttype': u'DocType',
'permlevel': 0
},
# DocType, Product Group
{
'doctype': 'DocType',
'name': u'Product Group'
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'item_group',
'fieldtype': u'Link',
'label': u'Item Group',
'options': u'Item Group'
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'label',
'fieldtype': u'Data',
'label': u'Label'
}
]

View File

@ -1,34 +0,0 @@
# ERPNext - web based ERP (http://erpnext.com)
# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import webnotes
class DocType:
def __init__(self, d, dl):
self.doc, self.doclist = d, dl
def on_update(self):
tmp = None
for d in self.doclist:
if d.doctype=="Product Group":
import json
tmp = json.dumps({"item_group": d.item_group, "label":d.label})
break
webnotes.conn.set_default("default_product_category", tmp)
from webnotes.session_cache import clear_cache
clear_cache('Guest')

View File

@ -1,72 +0,0 @@
# DocType, Products Settings
[
# These values are common in all dictionaries
{
'creation': '2012-03-27 14:36:48',
'docstatus': 0,
'modified': '2012-03-27 14:36:48',
'modified_by': u'Administrator',
'owner': u'Administrator'
},
# These values are common for all DocType
{
'_last_update': u'1327911653',
'colour': u'White:FFF',
'description': u'\n\n',
'doctype': 'DocType',
'issingle': 1,
'module': u'Website',
'name': '__common__',
'section_style': u'Simple',
'show_in_menu': 0,
'version': 4
},
# These values are common for all DocField
{
'colour': u'White:FFF',
'description': u'Product Groups that are listed on the website. The first product group from this list will be listed by default on the "Products Page"',
'doctype': u'DocField',
'fieldname': u'groups',
'fieldtype': u'Table',
'label': u'Groups',
'name': '__common__',
'options': u'Product Group',
'parent': u'Products Settings',
'parentfield': u'fields',
'parenttype': u'DocType',
'permlevel': 0
},
# These values are common for all DocPerm
{
'create': 1,
'doctype': u'DocPerm',
'name': '__common__',
'parent': u'Products Settings',
'parentfield': u'permissions',
'parenttype': u'DocType',
'permlevel': 0,
'read': 1,
'role': u'Website Manager',
'write': 1
},
# DocType, Products Settings
{
'doctype': 'DocType',
'name': u'Products Settings'
},
# DocPerm
{
'doctype': u'DocPerm'
},
# DocField
{
'doctype': u'DocField'
}
]

View File

@ -27,8 +27,13 @@ class DocType:
def validate(self):
"""make page for this product"""
# we need the name for the templates
if not self.doc.name:
self.doc.name = website.utils.page_name(self.doc.title)
self.autoname()
if self.doc.page_name:
webnotes.conn.sql("""delete from tabPage where name=%s""", self.doc.page_name)
p = website.utils.add_page(self.doc.name)
@ -39,8 +44,6 @@ class DocType:
self.doc.updated = global_date_format(self.doc.modified)
website.utils.markdown(self.doc, ['head_section','main_section', 'side_section'])
self.add_page_links()
with open(os.path.join(os.path.dirname(__file__), 'template.html'), 'r') as f:
p.content = Template(f.read()).render(doc=self.doc)

View File

@ -5,7 +5,7 @@
{
'creation': '2012-04-02 16:02:43',
'docstatus': 0,
'modified': '2012-04-25 16:03:57',
'modified': '2012-04-28 10:03:45',
'modified_by': u'Administrator',
'owner': u'Administrator'
},
@ -22,7 +22,7 @@
'name': '__common__',
'section_style': u'Simple',
'show_in_menu': 0,
'version': 16
'version': 17
},
# These values are common for all DocField
@ -31,8 +31,7 @@
'name': '__common__',
'parent': u'Web Page',
'parentfield': u'fields',
'parenttype': u'DocType',
'permlevel': 0
'parenttype': u'DocType'
},
# These values are common for all DocPerm
@ -71,7 +70,8 @@
'doctype': u'DocField',
'fieldname': u'sb0',
'fieldtype': u'Section Break',
'label': u'Title and Style'
'label': u'Title and Style',
'permlevel': 0
},
# DocField
@ -82,6 +82,7 @@
'fieldname': u'title',
'fieldtype': u'Data',
'label': u'Title',
'permlevel': 0,
'reqd': 1
},
@ -90,6 +91,7 @@
'doctype': u'DocField',
'fieldname': u'cb1',
'fieldtype': u'Column Break',
'permlevel': 0,
'width': u'50%'
},
@ -99,7 +101,8 @@
'fieldname': u'layout',
'fieldtype': u'Select',
'label': u'Layout',
'options': u'Two column with header\nTwo column\nSingle column'
'options': u'Two column with header\nTwo column\nSingle column',
'permlevel': 0
},
# DocField
@ -109,7 +112,8 @@
'doctype': u'DocField',
'fieldname': u'sb1',
'fieldtype': u'Section Break',
'label': u'Content'
'label': u'Content',
'permlevel': 0
},
# DocField
@ -119,7 +123,8 @@
'doctype': u'DocField',
'fieldname': u'head_section',
'fieldtype': u'Text',
'label': u'Head Section'
'label': u'Head Section',
'permlevel': 0
},
# DocField
@ -129,7 +134,8 @@
'doctype': u'DocField',
'fieldname': u'main_section',
'fieldtype': u'Code',
'label': u'Main Section'
'label': u'Main Section',
'permlevel': 0
},
# DocField
@ -139,7 +145,8 @@
'doctype': u'DocField',
'fieldname': u'side_section',
'fieldtype': u'Code',
'label': u'Side Section'
'label': u'Side Section',
'permlevel': 0
},
# DocField
@ -149,7 +156,8 @@
'doctype': u'DocField',
'fieldname': u'sb2',
'fieldtype': u'Section Break',
'label': u'More'
'label': u'More',
'permlevel': 0
},
# DocField
@ -158,7 +166,8 @@
'fieldname': u'text_align',
'fieldtype': u'Select',
'label': u'Text Align',
'options': u'Left\nCenter\nRight'
'options': u'Left\nCenter\nRight',
'permlevel': 0
},
# DocField
@ -167,7 +176,8 @@
'doctype': u'DocField',
'fieldname': u'insert_code',
'fieldtype': u'Check',
'label': u'Insert Code'
'label': u'Insert Code',
'permlevel': 0
},
# DocField
@ -175,7 +185,8 @@
'doctype': u'DocField',
'fieldname': u'javascript',
'fieldtype': u'Code',
'label': u'Javascript'
'label': u'Javascript',
'permlevel': 0
},
# DocField
@ -183,7 +194,8 @@
'doctype': u'DocField',
'fieldname': u'insert_style',
'fieldtype': u'Check',
'label': u'Insert Style'
'label': u'Insert Style',
'permlevel': 0
},
# DocField
@ -191,7 +203,17 @@
'doctype': u'DocField',
'fieldname': u'css',
'fieldtype': u'Code',
'label': u'CSS'
'label': u'CSS',
'permlevel': 0
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'page_name',
'fieldtype': u'Data',
'label': u'Page Name',
'permlevel': 1
},
# DocField
@ -202,6 +224,7 @@
'hidden': 1,
'label': u'File List',
'no_copy': 1,
'permlevel': 0,
'print_hide': 1
}
]

View File

@ -5,7 +5,7 @@
{
'creation': '2012-04-02 16:38:02',
'docstatus': 0,
'modified': '2012-04-27 16:41:40',
'modified': '2012-04-30 14:20:56',
'modified_by': u'Administrator',
'owner': u'Administrator'
},
@ -23,7 +23,7 @@
'name': '__common__',
'section_style': u'Simple',
'show_in_menu': 0,
'version': 11
'version': 1
},
# These values are common for all DocField
@ -109,6 +109,16 @@
'reqd': 1
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'default_product_category',
'fieldtype': u'Link',
'label': u'Default Product Category',
'options': u'Item Group',
'permlevel': 0
},
# DocField
{
'colour': u'White:FFF',

View File

@ -14,25 +14,16 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
// make sidelisting of categories
erpnext.product_item_group = {}
erpnext.make_product_categories = function(wrapper) {
wrapper.category_list = new wn.ui.Listing({
parent: $(wrapper).find('.more-categories').get(0),
query: 'select label, count(t2.name) as items, t1.item_group \
from `tabProduct Group` t1, `tabProduct` t2, tabItem t3\
where t1.parent="Products Settings" \
and t2.item = t3.name \
and t3.item_group = t1.item_group \
and ifnull(t2.published, 0)=1 \
group by t1.item_group \
order by t1.idx',
query: 'select count(name) as items, item_group \
from tabItem where is_sales_item="Yes" \
group by item_group order by items desc',
hide_refresh: true,
render_row: function(parent, data) {
parent.innerHTML = repl('<a href="#!products/%(label)s">%(label)s</a> (%(items)s)',
parent.innerHTML = repl('<a href="#!products/%(item_group)s">%(item_group)s</a> (%(items)s)',
data);
erpnext.product_item_group[data.label] = data.item_group;
}
});
wrapper.category_list.run();

View File

@ -1,11 +1,12 @@
<div class="layout_wrapper" id="content-products">
<h1 class="products-category"></h1>
<div class="web-main-section">
<div class="layout-wrapper layout-wrapper-background" id="content-products">
<div class="layout-main-section">
<h1 class="products-category"></h1>
<div class="products-search" style="margin-bottom: 15px;">
<input name="products-search" /><button class="btn" style="margin-left: 7px">Search</button>
</div>
<div class="products-list"></div>
</div>
<div class="web-side-section">
<div class="layout-side-section">
<h3>Categories</h3>
<div class="more-categories"></div>
</div>

View File

@ -19,11 +19,10 @@ erpnext.products = {}
wn.require('erpnext/website/js/product_category.js');
pscript.onload_products = function(wrapper) {
sys_defaults.default_product_category = JSON.parse(sys_defaults.default_product_category);
erpnext.make_product_categories(wrapper);
erpnext.products.wrapper = wrapper;
// make lists
erpnext.make_product_categories(wrapper);
erpnext.products.make_product_list(wrapper);
// button
@ -42,15 +41,15 @@ pscript.onshow_products = function(wrapper) {
}
erpnext.products.get_group = function() {
var route = window.location.hash.split('/');
route = wn.get_route();
if(route.length>1) {
// from url
var grp = erpnext.product_item_group[route[1]];
var grp = route[1];
var label = route[1];
} else {
// default
var grp = sys_defaults.default_product_category.item_group;
var label = sys_defaults.default_product_category.label;
var grp = wn.boot.website_settings.default_product_category;
var label = wn.boot.website_settings.default_product_category;
}
erpnext.products.cur_group = grp;
return {grp:grp, label:label};
@ -58,32 +57,39 @@ erpnext.products.get_group = function() {
erpnext.products.make_product_list = function(wrapper) {
wrapper.mainlist = new wn.ui.Listing({
parent: $(wrapper).find('.web-main-section').get(0),
parent: $(wrapper).find('.products-list').get(0),
run_btn: $(wrapper).find('.products-search .btn').get(0),
hide_refresh: true,
no_toolbar: true,
get_query: function() {
var srch = $('input[name="products-search"]').val()
var search_cond = 'and (t1.short_description like "%%(srch)s%"\
or t1.title like "%%(srch)s%")';
var search_cond = 'and (description like "%%(srch)s%"\
or item_name like "%%(srch)s%")';
args = {
search_cond: srch ? repl(search_cond, {srch:srch}) : '',
cat: erpnext.products.cur_group
};
return repl('select t1.name, t1.title, t1.thumbnail_image, \
t1.page_name, t1.short_description \
from tabProduct t1, tabItem t2 \
where t1.item = t2.name \
and ifnull(t1.published,0)=1 \
and t2.item_group="%(cat)s" \
return repl('select name, item_name, website_image, \
description, page_name \
from tabItem \
where is_sales_item="Yes" \
and item_group="%(cat)s" \
%(search_cond)s', args)
},
render_row: function(parent, data) {
parent.innerHTML = repl('<div style="float:left; width: 115px;">\
<img src="files/%(thumbnail_image)s" style="width:100px;"></div>\
parent.innerHTML = repl('<div style="float:left; width: 115px;" class="img-area">\
</div>\
<div style="float:left; width: 400px">\
<p><b><a href="#!%(page_name)s">%(title)s</a></b></p>\
<p>%(short_description)s</p></div>\
<div style="clear: both;"></div><hr />', data);
<p><b><a href="#!%(page_name)s">%(item_name)s</a></b></p>\
<p>%(description)s</p></div>\
<div style="clear: both;"></div>', data);
if(data.website_image) {
$(parent).find('.img-area').append(repl(
'<img src="files/%(website_image)s" style="width:100px;">', data))
} else {
$(parent).find('.img-area').append(wn.dom.placeholder(70,
data.item_name));
}
}
});
}

View File

@ -3,13 +3,11 @@
<div class="layout-main-section">
<h1>Website</h1>
<hr>
<div style="width: 48%; float: left;">
<h4><a href="#!List/Web Page">Web Page</a></h4>
<p class="help">Static (content) web page</p>
<br>
<h4><a href="#!List/Product">Product</a></h4>
<p class="help">Product listed in catolog</p>
<br>
<h4><a href="#!List/Blog">Blog</a></h4>
<p class="help">Weblog (blog) entry</p>
</div>
@ -19,9 +17,6 @@
<br>
<h4><a href="#!Form/Style Settings/Style Settings">Style Settings</a></h4>
<p class="help">Setup of fonts and background</p>
<br>
<h4><a href="#!Form/Products Settings/Products Settings">Products Settings</a></h4>
<p class="help">Setup product categories</p>
</div>
<div style="clear: both"></div>
<hr>
@ -31,9 +26,19 @@
<div class="layout-side-section">
<div class="psidebar">
<div class="section">
</div>
<p><b>Create website with static pages and blogs</b></p>
<ul>
<li>"Website Settings" - to setup header and footers.
<li>"Web Page" - for static web page.
<li>"Blog" - for blog entry.
</ul>
<p><b>Notes: </b></p>
<ul>
<li>All pages are accessible via `#` + page name appended to your url.
<li>Product catalogue is updated from Item Master (set Show in Website = 'Yes', in
Sales Settings).
</ul> </div>
</div>
</div>
<div style="clear: both;"></div>
</div>

View File

@ -170,17 +170,30 @@ var l=items.length;for(var i=0;i<l;i++){var src=items[i];wn.assets.execute(src);
/*
* lib/js/wn/dom.js
*/
wn.provide('wn.dom');wn.dom.by_id=function(id){return document.getElementById(id);}
wn.dom.eval=function(txt){if(!txt)return;var el=document.createElement('script');el.appendChild(document.createTextNode(txt));document.getElementsByTagName('head')[0].appendChild(el);}
wn.dom.set_style=function(txt){if(!txt)return;var se=document.createElement('style');se.type="text/css";if(se.styleSheet){se.styleSheet.cssText=txt;}else{se.appendChild(document.createTextNode(txt));}
document.getElementsByTagName('head')[0].appendChild(se);}
wn.dom.add=function(parent,newtag,className,cs,innerHTML,onclick){if(parent&&parent.substr)parent=wn.dom.by_id(parent);var c=document.createElement(newtag);if(parent)
wn.provide('wn.dom');wn.dom={by_id:function(id){return document.getElementById(id);},eval:function(txt){if(!txt)return;var el=document.createElement('script');el.appendChild(document.createTextNode(txt));document.getElementsByTagName('head')[0].appendChild(el);},set_style:function(txt){if(!txt)return;var se=document.createElement('style');se.type="text/css";if(se.styleSheet){se.styleSheet.cssText=txt;}else{se.appendChild(document.createTextNode(txt));}
document.getElementsByTagName('head')[0].appendChild(se);},add:function(parent,newtag,className,cs,innerHTML,onclick){if(parent&&parent.substr)parent=wn.dom.by_id(parent);var c=document.createElement(newtag);if(parent)
parent.appendChild(c);if(className){if(newtag.toLowerCase()=='img')
c.src=className
else
c.className=className;}
if(cs)wn.dom.css(c,cs);if(innerHTML)c.innerHTML=innerHTML;if(onclick)c.onclick=onclick;return c;}
wn.dom.css=function(ele,s){if(ele&&s){for(var i in s)ele.style[i]=s[i];};return ele;}
if(cs)wn.dom.css(c,cs);if(innerHTML)c.innerHTML=innerHTML;if(onclick)c.onclick=onclick;return c;},css:function(ele,s){if(ele&&s){for(var i in s)ele.style[i]=s[i];};return ele;},placeholder:function(dim,letter){function getsinglecol(){return Math.min(Math.round(Math.random()*9)*Math.round(Math.random()*1)+3,9)}
function getcol(){return''+getsinglecol()+getsinglecol()+getsinglecol();}
args={width:Math.round(flt(dim)*0.7)+'px',height:Math.round(flt(dim)*0.7)+'px',padding:Math.round(flt(dim)*0.15)+'px','font-size':Math.round(flt(dim)*0.6)+'px',col1:getcol(),col2:getcol(),letter:letter.substr(0,1).toUpperCase()}
return repl('<div style="\
height: %(height)s; \
width: %(width)s; \
font-size: %(font-size)s; \
color: #fff; \
text-align: center; \
padding: %(padding)s; \
background: -moz-linear-gradient(top, #%(col1)s 0%, #%(col2)s 99%); /* FF3.6+ */\
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#%(col1)s), color-stop(99%,#%(col2)s)); /* Chrome,Safari4+ */\
background: -webkit-linear-gradient(top, #%(col1)s 0%,#%(col2)s 99%); /* Chrome10+,Safari5.1+ */\
background: -o-linear-gradient(top, #%(col1)s 0%,#%(col2)s 99%); /* Opera 11.10+ */\
background: -ms-linear-gradient(top, #%(col1)s 0%,#%(col2)s 99%); /* IE10+ */\
background: linear-gradient(top, #%(col1)s 0%,#%(col2)s 99%); /* W3C */\
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr=\'#%(col1)s\', endColorstr=\'#%(col2)s\',GradientType=0 ); /* IE6-9 */\
">%(letter)s</div>',args);}}
wn.get_cookie=function(c){var t=""+document.cookie;var ind=t.indexOf(c);if(ind==-1||c=="")return"";var ind1=t.indexOf(';',ind);if(ind1==-1)ind1=t.length;return unescape(t.substring(ind+c.length+1,ind1));}
wn.dom.set_box_shadow=function(ele,spread){$(ele).css('-moz-box-shadow','0px 0px '+spread+'px rgba(0,0,0,0.3);')
$(ele).css('-webkit-box-shadow','0px 0px '+spread+'px rgba(0,0,0,0.3);')
@ -313,7 +326,7 @@ if(this.args)
$.extend(args,this.args)
if(this.get_args){$.extend(args,this.get_args(opts));}
return args;},render_results:function(r){if(this.start==0)this.clear();this.$w.find('.btn-more').toggle(false);if(r.message)r.values=r.message;if(r.values&&r.values.length){this.data=this.data.concat(r.values);this.render_list(r.values);this.update_paging(r.values);}else{if(this.start==0){this.$w.find('.result').toggle(false);this.$w.find('.no-result').toggle(true);}}
if(this.onrun)this.onrun();if(this.callback)this.callback(r);},render_list:function(values){var m=Math.min(values.length,this.page_length);for(var i=0;i<m;i++){this.render_row(this.add_row(),values[i],this,i);}},update_paging:function(values){if(values.length>=this.page_length){this.$w.find('.btn-more').toggle(true);this.start+=this.page_length;}},add_row:function(){return this.$w.find('.result-list').append('<div class="list-row">').find('.list-row:last').get(0);},refresh:function(){this.run();},add_limits:function(){this.query+=' LIMIT '+this.start+','+(this.page_length+1);}});
if(this.onrun)this.onrun();if(this.callback)this.callback(r);},render_list:function(values){var m=Math.min(values.length,this.page_length);for(var i=0;i<m;i++){this.render_row(this.add_row(),values[i],this,i);}},update_paging:function(values){if(values.length>=this.page_length){this.$w.find('.btn-more').toggle(true);this.start+=this.page_length;}},add_row:function(){return $('<div class="list-row">').appendTo(this.$w.find('.result-list')).get(0);},refresh:function(){this.run();},add_limits:function(){this.query+=' LIMIT '+this.start+','+(this.page_length+1);}});
/*
* lib/js/wn/ui/filters.js
*/
@ -1368,7 +1381,7 @@ wn.ui.toolbar.NewDialog=wn.ui.toolbar.SelectorDialog.extend({init:function(){thi
/*
* lib/js/wn/ui/toolbar/search.js
*/
wn.ui.toolbar.Search=wn.ui.toolbar.SelectorDialog.extend({init:function(){this._super({title:"Search",execute:function(val){selector.set_search(val);selector.show();},});this.set_values(profile.can_search.join(',').split(','));makeselector();}});
wn.ui.toolbar.Search=wn.ui.toolbar.SelectorDialog.extend({init:function(){this._super({title:"Search",execute:function(val){selector.set_search(val);selector.show();},});this.set_values(wn.boot.profile.can_search.join(',').split(','));makeselector();}});
/*
* lib/js/wn/ui/toolbar/report.js
*/
@ -1902,22 +1915,20 @@ _f.Grid.prototype.refresh_cell=function(docname,fieldname){for(var r=0;r<this.ta
_f.cur_grid;_f.cur_grid_ridx;_f.Grid.prototype.set_cell_value=function(cell){if(cell.row.is_newrow)return;var hc=this.head_row.cells[cell.cellIndex];if(hc.fieldname){var v=locals[hc.doctype][cell.row.docname][hc.fieldname];}else{var v=(cell.row.rowIndex+1);}
if(v==null){v='';}
var me=this;if(cell.cellIndex){var ft=hc.fieldtype;if(ft=='Link'&&cur_frm.doc.docstatus<1)ft='Data';$s(cell.div,v,ft,hc.options);}else{cell.div.style.padding='2px';cell.div.style.textAlign='left';cell.innerHTML='';var t=make_table(cell,1,3,'60px',['20px','20px','20px'],{verticalAlign:'middle',padding:'2px'});$y($td(t,0,0),{paddingLeft:'4px'});$td(t,0,0).innerHTML=cell.row.rowIndex+1;if(cur_frm.editable&&this.can_edit){var ed=$a($td(t,0,1),'i','icon-edit',{cursor:'pointer'});ed.cell=cell;ed.title='Edit Row';ed.onclick=function(){_f.cur_grid=me;_f.cur_grid_ridx=this.cell.row.rowIndex;_f.edit_record(me.doctype,this.cell.row.docname,1);}}else{cell.div.innerHTML=(cell.row.rowIndex+1);cell.div.style.cursor='default';cell.div.onclick=function(){}}}}
$(document).bind('click',function(e){var is_target_toolbar=function(){return $(e.target).parents('.grid_tbarlinks').length;}
$(document).bind('click',function(e){var me=this;var is_target_toolbar=function(){return $(e.target).parents('.grid_tbarlinks').length;}
var is_target_input=function(){if(e.target.tagName.toLowerCase()=='option')return true;return $(e.target).parents().get().indexOf(_f.cur_grid_cell)!=-1;}
if(_f.cur_grid_cell&&!is_target_input()&&!is_target_toolbar()){if(!(text_dialog&&text_dialog.display)&&!datepicker_active&&!(selector&&selector.display)){setTimeout('_f.cur_grid_cell.grid.cell_deselect()',500);return false;}}});_f.Grid.prototype.cell_deselect=function(){if(_f.cur_grid_cell){var c=_f.cur_grid_cell;c.grid.remove_template(c);c.div.className='grid_cell_div';if(c.is_odd)c.div.style.border='2px solid '+c.grid.alt_row_bg;else c.div.style.border='2px solid #FFF';_f.cur_grid_cell=null;}}
_f.Grid.prototype.cell_select=function(cell,ri,ci){if(ri!=null&&ci!=null)
_f.Grid.prototype.cell_select=function(cell,ri,ci){if(_f.cur_grid_cell==cell&&cell.hc)return;if(ri!=null&&ci!=null)
cell=this.tab.rows[ri].cells[ci];var hc=this.head_row.cells[cell.cellIndex];if(!hc.template){this.make_template(hc);}
hc.template.perm=this.field?this.field.perm:hc.perm;if(hc.fieldname&&hc.template.get_status()=='Write'){this.cell_deselect();cell.div.style.border='2px solid #88F';_f.cur_grid_cell=cell;this.add_template(cell);}}
_f.Grid.prototype.add_template=function(cell){if(!cell.row.docname&&this.add_newrow){this.add_newrow();this.cell_select(cell);}else{var hc=this.head_row.cells[cell.cellIndex];cell.div.innerHTML='';cell.div.appendChild(hc.template.wrapper);hc.template.activate(cell.row.docname);hc.template.activated=1;if(hc.template.input&&hc.template.input.set_width){hc.template.input.set_width($(cell).width());}}}
_f.Grid.prototype.add_template=function(cell){if(!cell.row.docname&&this.add_newrow){this.add_newrow();this.cell_select(cell);}else{var hc=this.head_row.cells[cell.cellIndex];cell.div.innerHTML='';cell.div.appendChild(hc.template.wrapper);hc.template.activate(cell.row.docname);hc.template.activated=1;cell.hc=hc;if(hc.template.input&&hc.template.input.set_width){hc.template.input.set_width($(cell).width());}}}
_f.Grid.prototype.get_field=function(fieldname){for(var i=0;i<this.head_row.cells.length;i++){var hc=this.head_row.cells[i];if(hc.fieldname==fieldname){if(!hc.template){this.make_template(hc);}
return hc.template;}}
return{}}
_f.grid_date_cell='';_f.grid_refresh_date=function(){_f.grid_date_cell.grid.set_cell_value(_f.grid_date_cell);}
_f.grid_refresh_field=function(temp,input){if(input.value!=_f.get_value(temp.doctype,temp.docname,temp.df.fieldname))
if(input.onchange)input.onchange();}
_f.Grid.prototype.remove_template=function(cell){var hc=this.head_row.cells[cell.cellIndex];if(!hc.template)return;if(!hc.template.activated)return;if(hc.template.txt){if(hc.template.df.fieldtype=='Date'){_f.grid_date_cell=cell;setTimeout('_f.grid_refresh_date()',100);}
if(hc.template.txt.value)
_f.grid_refresh_field(hc.template,hc.template.txt);}else if(hc.template.input){_f.grid_refresh_field(hc.template,hc.template.input);}
_f.grid_refresh_field=function(temp,input){if($(input).val()!=_f.get_value(temp.doctype,temp.docname,temp.df.fieldname))
$(input).trigger('change');}
_f.Grid.prototype.remove_template=function(cell){var hc=this.head_row.cells[cell.cellIndex];if(!hc.template)return;if(!hc.template.activated)return;if(hc.template.df.fieldtype=='Date'){_f.grid_date_cell=cell;setTimeout('_f.grid_refresh_date()',100);}else{var input=hc.template.txt||hc.template.input;_f.grid_refresh_field(hc.template,input)}
if(hc.template&&hc.template.wrapper.parentNode)
cell.div.removeChild(hc.template.wrapper);this.set_cell_value(cell);hc.template.activated=0;}
_f.Grid.prototype.notify_keypress=function(e,keycode){if(keycode>=37&&keycode<=40&&e.shiftKey){if(text_dialog&&text_dialog.display){return;}}else
@ -2199,7 +2210,7 @@ me.dialog.clear();me.dialog.show();}});
wn.Application=Class.extend({init:function(){this.load_bootinfo();this.make_page_container();this.make_nav_bar();this.set_favicon();$(document).trigger('startup');wn.route();},load_bootinfo:function(){LocalDB.sync(wn.boot.docs);wn.control_panel=wn.boot.control_panel;if(wn.boot.error_messages)
console.log(wn.boot.error_messages)
if(wn.boot.server_messages)
msgprint(wn.boot.server_messages);this.set_globals();},set_globals:function(){profile=wn.boot.profile;user=wn.boot.profile.name;user_fullname=wn.user_info(user).fullname;user_defaults=profile.defaults;user_roles=profile.roles;user_email=profile.email;sys_defaults=wn.boot.sysdefaults;},make_page_container:function(){wn.container=new wn.views.Container();wn.views.make_403();wn.views.make_404();$('#startup_div').toggle(false);$('#body_div').toggle(true);},make_nav_bar:function(){if(wn.user.name!='Guest'){wn.container.wntoolbar=new wn.ui.toolbar.Toolbar();}},logout:function(){var me=this;wn.call({method:'logout',callback:function(r){if(r.exc){console.log(r.exc);return;}
msgprint(wn.boot.server_messages);this.set_globals();},set_globals:function(){profile=wn.boot.profile;user=wn.boot.profile.name;user_fullname=wn.user_info(user).fullname;user_defaults=profile.defaults;user_roles=profile.roles;user_email=profile.email;sys_defaults=wn.boot.sysdefaults;},make_page_container:function(){wn.container=new wn.views.Container();wn.views.make_403();wn.views.make_404();},make_nav_bar:function(){if(wn.user.name!='Guest'){wn.container.wntoolbar=new wn.ui.toolbar.Toolbar();}},logout:function(){var me=this;wn.call({method:'logout',callback:function(r){if(r.exc){console.log(r.exc);return;}
me.redirect_to_login();}})},redirect_to_login:function(){window.location.hash='';window.location.reload();},set_favicon:function(){var link=$('link[type="image/x-icon"]').remove().attr("href");var favicon='\
<link rel="shortcut icon" href="'+link+'" type="image/x-icon"> \
<link rel="icon" href="'+link+'" type="image/x-icon">'

View File

@ -57,17 +57,30 @@ var l=items.length;for(var i=0;i<l;i++){var src=items[i];wn.assets.execute(src);
/*
* lib/js/wn/dom.js
*/
wn.provide('wn.dom');wn.dom.by_id=function(id){return document.getElementById(id);}
wn.dom.eval=function(txt){if(!txt)return;var el=document.createElement('script');el.appendChild(document.createTextNode(txt));document.getElementsByTagName('head')[0].appendChild(el);}
wn.dom.set_style=function(txt){if(!txt)return;var se=document.createElement('style');se.type="text/css";if(se.styleSheet){se.styleSheet.cssText=txt;}else{se.appendChild(document.createTextNode(txt));}
document.getElementsByTagName('head')[0].appendChild(se);}
wn.dom.add=function(parent,newtag,className,cs,innerHTML,onclick){if(parent&&parent.substr)parent=wn.dom.by_id(parent);var c=document.createElement(newtag);if(parent)
wn.provide('wn.dom');wn.dom={by_id:function(id){return document.getElementById(id);},eval:function(txt){if(!txt)return;var el=document.createElement('script');el.appendChild(document.createTextNode(txt));document.getElementsByTagName('head')[0].appendChild(el);},set_style:function(txt){if(!txt)return;var se=document.createElement('style');se.type="text/css";if(se.styleSheet){se.styleSheet.cssText=txt;}else{se.appendChild(document.createTextNode(txt));}
document.getElementsByTagName('head')[0].appendChild(se);},add:function(parent,newtag,className,cs,innerHTML,onclick){if(parent&&parent.substr)parent=wn.dom.by_id(parent);var c=document.createElement(newtag);if(parent)
parent.appendChild(c);if(className){if(newtag.toLowerCase()=='img')
c.src=className
else
c.className=className;}
if(cs)wn.dom.css(c,cs);if(innerHTML)c.innerHTML=innerHTML;if(onclick)c.onclick=onclick;return c;}
wn.dom.css=function(ele,s){if(ele&&s){for(var i in s)ele.style[i]=s[i];};return ele;}
if(cs)wn.dom.css(c,cs);if(innerHTML)c.innerHTML=innerHTML;if(onclick)c.onclick=onclick;return c;},css:function(ele,s){if(ele&&s){for(var i in s)ele.style[i]=s[i];};return ele;},placeholder:function(dim,letter){function getsinglecol(){return Math.min(Math.round(Math.random()*9)*Math.round(Math.random()*1)+3,9)}
function getcol(){return''+getsinglecol()+getsinglecol()+getsinglecol();}
args={width:Math.round(flt(dim)*0.7)+'px',height:Math.round(flt(dim)*0.7)+'px',padding:Math.round(flt(dim)*0.15)+'px','font-size':Math.round(flt(dim)*0.6)+'px',col1:getcol(),col2:getcol(),letter:letter.substr(0,1).toUpperCase()}
return repl('<div style="\
height: %(height)s; \
width: %(width)s; \
font-size: %(font-size)s; \
color: #fff; \
text-align: center; \
padding: %(padding)s; \
background: -moz-linear-gradient(top, #%(col1)s 0%, #%(col2)s 99%); /* FF3.6+ */\
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#%(col1)s), color-stop(99%,#%(col2)s)); /* Chrome,Safari4+ */\
background: -webkit-linear-gradient(top, #%(col1)s 0%,#%(col2)s 99%); /* Chrome10+,Safari5.1+ */\
background: -o-linear-gradient(top, #%(col1)s 0%,#%(col2)s 99%); /* Opera 11.10+ */\
background: -ms-linear-gradient(top, #%(col1)s 0%,#%(col2)s 99%); /* IE10+ */\
background: linear-gradient(top, #%(col1)s 0%,#%(col2)s 99%); /* W3C */\
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr=\'#%(col1)s\', endColorstr=\'#%(col2)s\',GradientType=0 ); /* IE6-9 */\
">%(letter)s</div>',args);}}
wn.get_cookie=function(c){var t=""+document.cookie;var ind=t.indexOf(c);if(ind==-1||c=="")return"";var ind1=t.indexOf(';',ind);if(ind1==-1)ind1=t.length;return unescape(t.substring(ind+c.length+1,ind1));}
wn.dom.set_box_shadow=function(ele,spread){$(ele).css('-moz-box-shadow','0px 0px '+spread+'px rgba(0,0,0,0.3);')
$(ele).css('-webkit-box-shadow','0px 0px '+spread+'px rgba(0,0,0,0.3);')
@ -200,7 +213,7 @@ if(this.args)
$.extend(args,this.args)
if(this.get_args){$.extend(args,this.get_args(opts));}
return args;},render_results:function(r){if(this.start==0)this.clear();this.$w.find('.btn-more').toggle(false);if(r.message)r.values=r.message;if(r.values&&r.values.length){this.data=this.data.concat(r.values);this.render_list(r.values);this.update_paging(r.values);}else{if(this.start==0){this.$w.find('.result').toggle(false);this.$w.find('.no-result').toggle(true);}}
if(this.onrun)this.onrun();if(this.callback)this.callback(r);},render_list:function(values){var m=Math.min(values.length,this.page_length);for(var i=0;i<m;i++){this.render_row(this.add_row(),values[i],this,i);}},update_paging:function(values){if(values.length>=this.page_length){this.$w.find('.btn-more').toggle(true);this.start+=this.page_length;}},add_row:function(){return this.$w.find('.result-list').append('<div class="list-row">').find('.list-row:last').get(0);},refresh:function(){this.run();},add_limits:function(){this.query+=' LIMIT '+this.start+','+(this.page_length+1);}});
if(this.onrun)this.onrun();if(this.callback)this.callback(r);},render_list:function(values){var m=Math.min(values.length,this.page_length);for(var i=0;i<m;i++){this.render_row(this.add_row(),values[i],this,i);}},update_paging:function(values){if(values.length>=this.page_length){this.$w.find('.btn-more').toggle(true);this.start+=this.page_length;}},add_row:function(){return $('<div class="list-row">').appendTo(this.$w.find('.result-list')).get(0);},refresh:function(){this.run();},add_limits:function(){this.query+=' LIMIT '+this.start+','+(this.page_length+1);}});
/*
* lib/js/wn/ui/filters.js
*/
@ -808,7 +821,7 @@ if(errfld.length)msgprint('<b>Mandatory fields required in '+
wn.Application=Class.extend({init:function(){this.load_bootinfo();this.make_page_container();this.make_nav_bar();this.set_favicon();$(document).trigger('startup');wn.route();},load_bootinfo:function(){LocalDB.sync(wn.boot.docs);wn.control_panel=wn.boot.control_panel;if(wn.boot.error_messages)
console.log(wn.boot.error_messages)
if(wn.boot.server_messages)
msgprint(wn.boot.server_messages);this.set_globals();},set_globals:function(){profile=wn.boot.profile;user=wn.boot.profile.name;user_fullname=wn.user_info(user).fullname;user_defaults=profile.defaults;user_roles=profile.roles;user_email=profile.email;sys_defaults=wn.boot.sysdefaults;},make_page_container:function(){wn.container=new wn.views.Container();wn.views.make_403();wn.views.make_404();$('#startup_div').toggle(false);$('#body_div').toggle(true);},make_nav_bar:function(){if(wn.user.name!='Guest'){wn.container.wntoolbar=new wn.ui.toolbar.Toolbar();}},logout:function(){var me=this;wn.call({method:'logout',callback:function(r){if(r.exc){console.log(r.exc);return;}
msgprint(wn.boot.server_messages);this.set_globals();},set_globals:function(){profile=wn.boot.profile;user=wn.boot.profile.name;user_fullname=wn.user_info(user).fullname;user_defaults=profile.defaults;user_roles=profile.roles;user_email=profile.email;sys_defaults=wn.boot.sysdefaults;},make_page_container:function(){wn.container=new wn.views.Container();wn.views.make_403();wn.views.make_404();},make_nav_bar:function(){if(wn.user.name!='Guest'){wn.container.wntoolbar=new wn.ui.toolbar.Toolbar();}},logout:function(){var me=this;wn.call({method:'logout',callback:function(r){if(r.exc){console.log(r.exc);return;}
me.redirect_to_login();}})},redirect_to_login:function(){window.location.hash='';window.location.reload();},set_favicon:function(){var link=$('link[type="image/x-icon"]').remove().attr("href");var favicon='\
<link rel="shortcut icon" href="'+link+'" type="image/x-icon"> \
<link rel="icon" href="'+link+'" type="image/x-icon">'