Sourced wnframework-modules from Google Code as erpnext
diff --git a/tools/Module Def/Tools/Tools.txt b/tools/Module Def/Tools/Tools.txt
new file mode 100644
index 0000000..428f079
--- /dev/null
+++ b/tools/Module Def/Tools/Tools.txt
@@ -0,0 +1,358 @@
+[
+ {
+ '_last_update': None,
+ 'creation': '2010-11-30 22:45:03',
+ 'disabled': 'Yes',
+ 'docstatus': 0,
+ 'doctype': 'Module Def',
+ 'doctype_list': None,
+ 'file_list': None,
+ 'idx': None,
+ 'is_hidden': None,
+ 'last_updated_date': '2011-02-12 11:57:57',
+ 'modified': '2010-09-25 00:00:00',
+ 'modified_by': 'Administrator',
+ 'module_desc': None,
+ 'module_icon': 'id_card.png',
+ 'module_label': 'Organize',
+ 'module_name': 'Tools',
+ 'module_page': 'Organize',
+ 'module_seq': 3,
+ 'name': 'Tools',
+ 'owner': 'Administrator',
+ 'parent': None,
+ 'parentfield': None,
+ 'parenttype': None,
+ 'trash_reason': None,
+ 'widget_code': None
+ },
+ {
+ 'click_function': None,
+ 'creation': '2010-11-30 22:45:03',
+ 'description': 'Shared Calendar of important events, reminders',
+ 'display_name': 'Calendar',
+ 'doc_name': '_calendar',
+ 'doc_type': 'Pages',
+ 'docstatus': 0,
+ 'doctype': 'Module Def Item',
+ 'fields': None,
+ 'hide': None,
+ 'icon': 'calendar.gif',
+ 'idx': 1,
+ 'modified': '2011-03-24 15:04:47',
+ 'modified_by': 'Administrator',
+ 'name': 'MDI00252',
+ 'owner': 'Administrator',
+ 'parent': 'Tools',
+ 'parentfield': 'items',
+ 'parenttype': 'Module Def'
+ },
+ {
+ 'click_function': None,
+ 'creation': '2010-11-30 22:45:03',
+ 'description': 'Manage your contact details',
+ 'display_name': 'Manage Contacts',
+ 'doc_name': 'Contact Page',
+ 'doc_type': 'Pages',
+ 'docstatus': 0,
+ 'doctype': 'Module Def Item',
+ 'fields': None,
+ 'hide': None,
+ 'icon': 'table.gif',
+ 'idx': 2,
+ 'modified': '2011-03-24 15:04:47',
+ 'modified_by': 'Administrator',
+ 'name': 'MDI00253',
+ 'owner': 'Administrator',
+ 'parent': 'Tools',
+ 'parentfield': 'items',
+ 'parenttype': 'Module Def'
+ },
+ {
+ 'click_function': None,
+ 'creation': '2010-11-30 22:45:03',
+ 'description': 'Standardized business letters',
+ 'display_name': 'Business Letters',
+ 'doc_name': 'Business Letter',
+ 'doc_type': 'Forms',
+ 'docstatus': 0,
+ 'doctype': 'Module Def Item',
+ 'fields': 'to_contact\ntemplate',
+ 'hide': None,
+ 'icon': 'page.gif',
+ 'idx': 3,
+ 'modified': '2011-03-24 15:04:47',
+ 'modified_by': 'Administrator',
+ 'name': 'MDI00254',
+ 'owner': 'Administrator',
+ 'parent': 'Tools',
+ 'parentfield': 'items',
+ 'parenttype': 'Module Def'
+ },
+ {
+ 'click_function': None,
+ 'creation': '2010-11-30 22:45:03',
+ 'description': 'Online storage of files in a folder structure that you can share with your users',
+ 'display_name': 'File Uploads',
+ 'doc_name': 'File Browser',
+ 'doc_type': 'Pages',
+ 'docstatus': 0,
+ 'doctype': 'Module Def Item',
+ 'fields': None,
+ 'hide': None,
+ 'icon': 'folder.gif',
+ 'idx': 4,
+ 'modified': '2011-03-24 15:04:47',
+ 'modified_by': 'Administrator',
+ 'name': 'MDI00255',
+ 'owner': 'Administrator',
+ 'parent': 'Tools',
+ 'parentfield': 'items',
+ 'parenttype': 'Module Def'
+ },
+ {
+ 'click_function': None,
+ 'creation': '2010-11-30 22:45:03',
+ 'description': None,
+ 'display_name': 'SMS Center',
+ 'doc_name': 'SMS Center',
+ 'doc_type': 'Single DocType',
+ 'docstatus': 0,
+ 'doctype': 'Module Def Item',
+ 'fields': None,
+ 'hide': None,
+ 'icon': None,
+ 'idx': 5,
+ 'modified': '2011-03-24 15:04:47',
+ 'modified_by': 'Administrator',
+ 'name': 'MDI00256',
+ 'owner': 'Administrator',
+ 'parent': 'Tools',
+ 'parentfield': 'items',
+ 'parenttype': 'Module Def'
+ },
+ {
+ 'creation': '2010-11-30 22:45:03',
+ 'docstatus': 0,
+ 'doctype': 'Module Def Role',
+ 'idx': 1,
+ 'modified': '2010-11-30 22:45:03',
+ 'modified_by': 'Administrator',
+ 'name': 'MDR00059',
+ 'owner': 'Administrator',
+ 'parent': 'Tools',
+ 'parentfield': 'roles',
+ 'parenttype': 'Module Def',
+ 'role': 'Accounts User'
+ },
+ {
+ 'creation': '2010-11-30 22:45:03',
+ 'docstatus': 0,
+ 'doctype': 'Module Def Role',
+ 'idx': 2,
+ 'modified': '2010-11-30 22:45:03',
+ 'modified_by': 'Administrator',
+ 'name': 'MDR00060',
+ 'owner': 'Administrator',
+ 'parent': 'Tools',
+ 'parentfield': 'roles',
+ 'parenttype': 'Module Def',
+ 'role': 'Accounts Manager'
+ },
+ {
+ 'creation': '2010-11-30 22:45:03',
+ 'docstatus': 0,
+ 'doctype': 'Module Def Role',
+ 'idx': 3,
+ 'modified': '2010-11-30 22:45:03',
+ 'modified_by': 'Administrator',
+ 'name': 'MDR00061',
+ 'owner': 'Administrator',
+ 'parent': 'Tools',
+ 'parentfield': 'roles',
+ 'parenttype': 'Module Def',
+ 'role': 'HR User'
+ },
+ {
+ 'creation': '2010-11-30 22:45:03',
+ 'docstatus': 0,
+ 'doctype': 'Module Def Role',
+ 'idx': 4,
+ 'modified': '2010-11-30 22:45:03',
+ 'modified_by': 'Administrator',
+ 'name': 'MDR00062',
+ 'owner': 'Administrator',
+ 'parent': 'Tools',
+ 'parentfield': 'roles',
+ 'parenttype': 'Module Def',
+ 'role': 'HR Manager'
+ },
+ {
+ 'creation': '2010-11-30 22:45:03',
+ 'docstatus': 0,
+ 'doctype': 'Module Def Role',
+ 'idx': 5,
+ 'modified': '2010-11-30 22:45:03',
+ 'modified_by': 'Administrator',
+ 'name': 'MDR00063',
+ 'owner': 'Administrator',
+ 'parent': 'Tools',
+ 'parentfield': 'roles',
+ 'parenttype': 'Module Def',
+ 'role': 'Material User'
+ },
+ {
+ 'creation': '2010-11-30 22:45:03',
+ 'docstatus': 0,
+ 'doctype': 'Module Def Role',
+ 'idx': 6,
+ 'modified': '2010-11-30 22:45:03',
+ 'modified_by': 'Administrator',
+ 'name': 'MDR00064',
+ 'owner': 'Administrator',
+ 'parent': 'Tools',
+ 'parentfield': 'roles',
+ 'parenttype': 'Module Def',
+ 'role': 'Material Master Manager'
+ },
+ {
+ 'creation': '2010-11-30 22:45:03',
+ 'docstatus': 0,
+ 'doctype': 'Module Def Role',
+ 'idx': 7,
+ 'modified': '2010-11-30 22:45:03',
+ 'modified_by': 'Administrator',
+ 'name': 'MDR00065',
+ 'owner': 'Administrator',
+ 'parent': 'Tools',
+ 'parentfield': 'roles',
+ 'parenttype': 'Module Def',
+ 'role': 'Material Manager'
+ },
+ {
+ 'creation': '2010-11-30 22:45:03',
+ 'docstatus': 0,
+ 'doctype': 'Module Def Role',
+ 'idx': 8,
+ 'modified': '2010-11-30 22:45:03',
+ 'modified_by': 'Administrator',
+ 'name': 'MDR00066',
+ 'owner': 'Administrator',
+ 'parent': 'Tools',
+ 'parentfield': 'roles',
+ 'parenttype': 'Module Def',
+ 'role': 'Purchase User'
+ },
+ {
+ 'creation': '2010-11-30 22:45:03',
+ 'docstatus': 0,
+ 'doctype': 'Module Def Role',
+ 'idx': 9,
+ 'modified': '2010-11-30 22:45:03',
+ 'modified_by': 'Administrator',
+ 'name': 'MDR00067',
+ 'owner': 'Administrator',
+ 'parent': 'Tools',
+ 'parentfield': 'roles',
+ 'parenttype': 'Module Def',
+ 'role': 'Purchase Master Manager'
+ },
+ {
+ 'creation': '2010-11-30 22:45:03',
+ 'docstatus': 0,
+ 'doctype': 'Module Def Role',
+ 'idx': 10,
+ 'modified': '2010-11-30 22:45:03',
+ 'modified_by': 'Administrator',
+ 'name': 'MDR00068',
+ 'owner': 'Administrator',
+ 'parent': 'Tools',
+ 'parentfield': 'roles',
+ 'parenttype': 'Module Def',
+ 'role': 'Purchase Manager'
+ },
+ {
+ 'creation': '2010-11-30 22:45:03',
+ 'docstatus': 0,
+ 'doctype': 'Module Def Role',
+ 'idx': 11,
+ 'modified': '2010-11-30 22:45:03',
+ 'modified_by': 'Administrator',
+ 'name': 'MDR00069',
+ 'owner': 'Administrator',
+ 'parent': 'Tools',
+ 'parentfield': 'roles',
+ 'parenttype': 'Module Def',
+ 'role': 'Production User'
+ },
+ {
+ 'creation': '2010-11-30 22:45:03',
+ 'docstatus': 0,
+ 'doctype': 'Module Def Role',
+ 'idx': 12,
+ 'modified': '2010-11-30 22:45:03',
+ 'modified_by': 'Administrator',
+ 'name': 'MDR00070',
+ 'owner': 'Administrator',
+ 'parent': 'Tools',
+ 'parentfield': 'roles',
+ 'parenttype': 'Module Def',
+ 'role': 'Production Manager'
+ },
+ {
+ 'creation': '2010-11-30 22:45:03',
+ 'docstatus': 0,
+ 'doctype': 'Module Def Role',
+ 'idx': 13,
+ 'modified': '2010-11-30 22:45:03',
+ 'modified_by': 'Administrator',
+ 'name': 'MDR00071',
+ 'owner': 'Administrator',
+ 'parent': 'Tools',
+ 'parentfield': 'roles',
+ 'parenttype': 'Module Def',
+ 'role': 'System Manager'
+ },
+ {
+ 'creation': '2010-11-30 22:45:03',
+ 'docstatus': 0,
+ 'doctype': 'Module Def Role',
+ 'idx': 14,
+ 'modified': '2010-11-30 22:45:03',
+ 'modified_by': 'Administrator',
+ 'name': 'MDR00072',
+ 'owner': 'Administrator',
+ 'parent': 'Tools',
+ 'parentfield': 'roles',
+ 'parenttype': 'Module Def',
+ 'role': 'Sales User'
+ },
+ {
+ 'creation': '2010-11-30 22:45:03',
+ 'docstatus': 0,
+ 'doctype': 'Module Def Role',
+ 'idx': 15,
+ 'modified': '2010-11-30 22:45:03',
+ 'modified_by': 'Administrator',
+ 'name': 'MDR00073',
+ 'owner': 'Administrator',
+ 'parent': 'Tools',
+ 'parentfield': 'roles',
+ 'parenttype': 'Module Def',
+ 'role': 'Sales Master Manager'
+ },
+ {
+ 'creation': '2010-11-30 22:45:03',
+ 'docstatus': 0,
+ 'doctype': 'Module Def Role',
+ 'idx': 16,
+ 'modified': '2010-11-30 22:45:03',
+ 'modified_by': 'Administrator',
+ 'name': 'MDR00074',
+ 'owner': 'Administrator',
+ 'parent': 'Tools',
+ 'parentfield': 'roles',
+ 'parenttype': 'Module Def',
+ 'role': 'Sales Manager'
+ }
+]
\ No newline at end of file
diff --git a/tools/__init__.py b/tools/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tools/__init__.py
diff --git a/tools/doctype/__init__.py b/tools/doctype/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tools/doctype/__init__.py
diff --git a/tools/doctype/activity_dashboard_control/__init__.py b/tools/doctype/activity_dashboard_control/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tools/doctype/activity_dashboard_control/__init__.py
diff --git a/tools/doctype/activity_dashboard_control/activity_dashboard_control.py b/tools/doctype/activity_dashboard_control/activity_dashboard_control.py
new file mode 100644
index 0000000..fde7552
--- /dev/null
+++ b/tools/doctype/activity_dashboard_control/activity_dashboard_control.py
@@ -0,0 +1,95 @@
+# Please edit this list and import only required elements
+import webnotes
+
+from webnotes.utils import add_days, add_months, add_years, cint, cstr, date_diff, default_fields, flt, fmt_money, formatdate, generate_hash, getTraceback, get_defaults, get_first_day, get_last_day, getdate, has_common, month_name, now, nowdate, replace_newlines, sendmail, set_default, str_esc_quote, user_format, validate_email_add
+from webnotes.model import db_exists
+from webnotes.model.doc import Document, addchild, removechild, getchildren, make_autoname, SuperDocType
+from webnotes.model.doclist import getlist, copy_doclist
+from webnotes.model.code import get_obj, get_server_obj, run_server_obj, updatedb, check_syntax
+from webnotes import session, form, is_testing, msgprint, errprint
+
+set = webnotes.conn.set
+sql = webnotes.conn.sql
+get_value = webnotes.conn.get_value
+in_transaction = webnotes.conn.in_transaction
+convert_to_lists = webnotes.conn.convert_to_lists
+
+# -----------------------------------------------------------------------------------------
+
+
+class DocType:
+ def __init__(self, doc, doclist=[]):
+ self.doc = doc
+ self.doclist = doclist
+
+
+ # get dashboard counts
+ # --------------------
+ def get_dashboard_counts(self, dt):
+ dtl = eval(dt)
+ dt = {}
+
+ for d in dtl:
+ # if Lead
+ if d=='Lead':
+ dt[d] = {'To follow up':sql("select count(name) from tabLead where status!='Converted' and docstatus=1")[0][0] or 0}
+
+ # if Enquiry
+ elif d=='Enquiries':
+ args = {}
+ args['Quotations to be sent'] = sql("select count(distinct(t2.name)) from `tabQuotation`t1, `tabEnquiry`t2 where t1.enq_no!=t2.name and t2.docstatus=1")[0][0] or 0
+ args['To follow up'] = sql("select count(name) from `tabQuotation` where docstatus=0")[0][0] or 0 #Draft
+ dt[d] = args
+
+ # if Sales Order
+ elif d=='Sales Order':
+ args = {}
+ args['To be delivered'] = sql("select count(name) from `tabSales Order` where per_delivered<100 and delivery_date>now() and docstatus=1")[0][0] or 0
+ args['To be billed'] = sql("select count(name) from `tabSales Order` where per_billed<100 and docstatus=1")[0][0] or 0
+ args['Overdue'] = sql("select count(name) from `tabSales Order` where per_delivered<100 and delivery_date<now() and docstatus=1")[0][0] or 0
+ args['To be submitted'] = sql("select count(name) from `tabSales Order` where status='Draft'")[0][0] or 0 #Draft
+ dt[d] = args
+
+ # if Invoice
+ elif d=='Invoices':
+ args = {}
+ args['To receive payment'] = sql("select count(name) from `tabReceivable Voucher` where docstatus=1 and due_date>now() and outstanding_amount!=0")[0][0] or 0
+ args['Overdue'] = sql("select count(name) from `tabReceivable Voucher` where docstatus=1 and due_date<now() and outstanding_amount!=0")[0][0] or 0
+ args['To be submitted'] = sql("select count(name) from `tabReceivable Voucher` where docstatus=0")[0][0] or 0 #Draft
+ dt[d] = args
+
+ # if Indent
+ elif d=='Indent':
+ args = {}
+ args['Purchase Order to be made'] = sql("select count(name) from `tabIndent` where per_ordered<100 and docstatus=1")[0][0] or 0
+ args['To be submitted'] = sql("select count(name) from `tabIndent` where status='Draft'")[0][0] or 0 #Draft
+ dt[d] = args
+
+ # if Purchase Order
+ elif d=='Purchase Order':
+ args = {}
+ args['To receive items'] = sql("select count(name) from `tabPurchase Order` where per_received<100 and docstatus=1")[0][0] or 0
+ args['To be billed'] = sql("select count(name) from `tabPurchase Order` where per_billed<100 and docstatus=1")[0][0] or 0
+ args['To be submitted'] = sql("select count(name) from `tabPurchase Order` where status='Draft'")[0][0] or 0 #Draft
+ dt[d] = args
+
+ # if Bills
+ elif d=='Bills':
+ args = {}
+ args['To be payed'] = sql("select count(name) from `tabPayable Voucher` where docstatus=1 and outstanding_amount!=0")[0][0] or 0
+ args['To be submitted'] = sql("select count(name) from `tabPayable Voucher` where docstatus=0")[0][0] or 0 #Draft
+ dt[d] = args
+
+ # if Tasks
+ elif d=='Tasks':
+ dt[d] = {'Open': sql("select count(name) from `tabTicket` where status='Open'")[0][0] or 0}
+
+ # if Maintenance
+ elif d=='Serial No':
+ args = {}
+ args['AMC to expire this month'] = sql("select count(name) from `tabSerial No` where docstatus=1 and month(getdate()) = month(amc_expiry_date) and year(getdate()) = year(amc_expiry_date)")[0][0] or 0
+ args['Warranty to expire this month'] = ql("select count(name) from `tabSerial No` where docstatus=1 and month(getdate()) = month(warranty_expiry_date) and year(getdate())=year(warranty_expiry_date)")[0][0] or 0
+ dt[d] = args
+
+ msgprint(dt)
+ return dt
\ No newline at end of file
diff --git a/tools/doctype/activity_dashboard_control/activity_dashboard_control.txt b/tools/doctype/activity_dashboard_control/activity_dashboard_control.txt
new file mode 100644
index 0000000..e55656d
--- /dev/null
+++ b/tools/doctype/activity_dashboard_control/activity_dashboard_control.txt
@@ -0,0 +1 @@
+[{'section_style': 'Simple', 'is_transaction_doc': None, 'creation': '2010-04-29 14:44:17', 'search_fields': None, 'module': 'Tools', 'doctype': 'DocType', 'change_log': None, 'print_outline': '', 'owner': 'Administrator', 'in_dialog': None, 'in_create': None, 'read_only': None, 'allow_email': None, 'dt_template': None, 'hide_heading': None, 'issingle': 1, 'allow_rename': None, 'smallicon': None, 'allow_attach': None, 'show_in_menu': None, 'max_attachments': None, 'version': 43, 'menu_index': None, 'docstatus': 0, 'allow_copy': None, 'istable': None, 'description': None, 'parent': None, 'server_code': None, 'allow_trash': None, 'allow_print': None, 'autoname': None, 'client_script_core': None, 'client_string': None, 'use_template': None, 'modified_by': 'nabin@webnotestech.com', 'document_type': None, 'name': 'Activity Dashboard Control', 'idx': None, 'hide_toolbar': None, 'colour': 'White:FFF', 'client_script': None, 'modified': '2010-09-20 14:06:57', 'server_code_error': ' ', 'name_case': '', 'parenttype': None, 'read_only_onload': None, 'server_code_core': None, 'server_code_compiled': None, 'parent_node': None, 'parentfield': None}]
\ No newline at end of file
diff --git a/tools/doctype/address/__init__.py b/tools/doctype/address/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tools/doctype/address/__init__.py
diff --git a/tools/doctype/address/address.comp.js b/tools/doctype/address/address.comp.js
new file mode 100644
index 0000000..0f6be69
--- /dev/null
+++ b/tools/doctype/address/address.comp.js
@@ -0,0 +1,2 @@
+
+cur_frm.cscript.onload=function(doc,cdt,cdn){if(doc.customer)cur_frm.add_fetch('customer','customer_name','customer_name');if(doc.supplier)cur_frm.add_fetch('supplier','supplier_name','supplier_name');}
\ No newline at end of file
diff --git a/tools/doctype/address/address.js b/tools/doctype/address/address.js
new file mode 100644
index 0000000..aa1d871
--- /dev/null
+++ b/tools/doctype/address/address.js
@@ -0,0 +1,5 @@
+cur_frm.cscript.onload = function(doc, cdt, cdn) {
+ if(doc.customer) cur_frm.add_fetch('customer', 'customer_name', 'customer_name');
+ if(doc.supplier) cur_frm.add_fetch('supplier', 'supplier_name', 'supplier_name');
+}
+
diff --git a/tools/doctype/address/address.py b/tools/doctype/address/address.py
new file mode 100644
index 0000000..dc17743
--- /dev/null
+++ b/tools/doctype/address/address.py
@@ -0,0 +1,56 @@
+# Please edit this list and import only required elements
+import webnotes
+
+from webnotes.model.doc import Document
+from webnotes import session, form, msgprint, errprint
+
+sql = webnotes.conn.sql
+
+# -----------------------------------------------------------------------------------------
+
+class DocType:
+ def __init__(self, doc, doclist=[]):
+ self.doc = doc
+ self.doclist = doclist
+
+ def autoname(self):
+ if self.doc.customer:
+ self.doc.name = self.doc.customer + '-' + self.doc.address_type
+ elif self.doc.supplier:
+ self.doc.name = self.doc.supplier + '-' + self.doc.address_type
+ elif self.doc.sales_partner:
+ self.doc.name = self.doc.sales_partner + '-' + self.doc.address_type
+
+ # filter out bad characters in name
+ self.doc.name = self.doc.name.replace('&','and').replace('.','').replace("'",'').replace('"','').replace(',','').replace('`','')
+
+#----------------------
+# Call to Validate
+#----------------------
+ def validate(self):
+ self.validate_primary_address()
+ self.validate_shipping_address()
+
+#----------------------
+# Validate that there can only be one primary address for particular customer, supplier
+#----------------------
+ def validate_primary_address(self):
+ if self.doc.is_primary_address == 1:
+ if self.doc.customer:
+ sql("update tabAddress set is_primary_address=0 where customer = '%s'" % (self.doc.customer))
+ elif self.doc.supplier:
+ sql("update tabAddress set is_primary_address=0 where supplier = '%s'" % (self.doc.supplier))
+ elif self.doc.sales_partner:
+ sql("update tabAddress set is_primary_address=0 where sales_partner = '%s'" % (self.doc.sales_partner))
+
+#----------------------
+# Validate that there can only be one shipping address for particular customer, supplier
+#----------------------
+ def validate_shipping_address(self):
+ if self.doc.is_shipping_address == 1:
+ if self.doc.customer:
+ sql("update tabAddress set is_shipping_address=0 where customer = '%s'" % (self.doc.customer))
+ elif self.doc.supplier:
+ sql("update tabAddress set is_shipping_address=0 where supplier = '%s'" % (self.doc.supplier))
+ elif self.doc.sales_partner:
+ sql("update tabAddress set is_shipping_address=0 where sales_partner = '%s'" % (self.doc.sales_partner))
diff --git a/tools/doctype/address/address.txt b/tools/doctype/address/address.txt
new file mode 100644
index 0000000..ee23f82
--- /dev/null
+++ b/tools/doctype/address/address.txt
@@ -0,0 +1,802 @@
+[
+ {
+ '_last_update': '1306307668',
+ '_user_tags': None,
+ 'allow_attach': None,
+ 'allow_copy': None,
+ 'allow_email': None,
+ 'allow_print': None,
+ 'allow_rename': None,
+ 'allow_trash': 1,
+ 'autoname': None,
+ 'change_log': None,
+ 'client_script': None,
+ 'client_script_core': None,
+ 'client_string': None,
+ 'colour': 'White:FFF',
+ 'creation': '2011-05-25 12:59:30',
+ 'description': None,
+ 'docstatus': 0,
+ 'doctype': 'DocType',
+ 'document_type': 'Master',
+ 'dt_template': None,
+ 'hide_heading': None,
+ 'hide_toolbar': None,
+ 'idx': None,
+ 'in_create': None,
+ 'in_dialog': 1,
+ 'is_transaction_doc': None,
+ 'issingle': None,
+ 'istable': None,
+ 'max_attachments': None,
+ 'menu_index': None,
+ 'modified': '2011-05-26 17:45:25',
+ 'modified_by': 'Administrator',
+ 'module': 'Tools',
+ 'name': 'Address',
+ 'name_case': None,
+ 'owner': 'Administrator',
+ 'parent': None,
+ 'parent_node': None,
+ 'parentfield': None,
+ 'parenttype': None,
+ 'print_outline': None,
+ 'read_only': None,
+ 'read_only_onload': None,
+ 'search_fields': None,
+ 'section_style': 'Simple',
+ 'server_code': None,
+ 'server_code_compiled': None,
+ 'server_code_core': None,
+ 'server_code_error': None,
+ 'show_in_menu': 0,
+ 'smallicon': None,
+ 'subject': None,
+ 'tag_fields': None,
+ 'use_template': None,
+ 'version': 41
+ },
+ {
+ 'amend': None,
+ 'cancel': 1,
+ 'create': 1,
+ 'creation': '2011-05-25 12:59:30',
+ 'docstatus': 0,
+ 'doctype': 'DocPerm',
+ 'execute': None,
+ 'idx': 1,
+ 'match': None,
+ 'modified': '2011-05-26 17:45:25',
+ 'modified_by': 'Administrator',
+ 'name': 'PERM00884',
+ 'owner': 'Administrator',
+ 'parent': 'Address',
+ 'parentfield': 'permissions',
+ 'parenttype': 'DocType',
+ 'permlevel': 0,
+ 'read': 1,
+ 'role': 'All',
+ 'submit': None,
+ 'write': 1
+ },
+ {
+ 'allow_on_submit': None,
+ 'colour': 'White:FFF',
+ 'creation': '2011-05-25 12:59:30',
+ 'default': None,
+ 'depends_on': None,
+ 'description': None,
+ 'docstatus': 0,
+ 'doctype': 'DocField',
+ 'fieldname': None,
+ 'fieldtype': 'Section Break',
+ 'hidden': None,
+ 'icon': None,
+ 'idx': 1,
+ 'in_filter': None,
+ 'label': 'Address Details',
+ 'modified': '2011-05-26 17:45:25',
+ 'modified_by': 'Administrator',
+ 'name': 'FL05072',
+ 'no_column': None,
+ 'no_copy': None,
+ 'oldfieldname': None,
+ 'oldfieldtype': None,
+ 'options': None,
+ 'owner': 'Administrator',
+ 'parent': 'Address',
+ 'parentfield': 'fields',
+ 'parenttype': 'DocType',
+ 'permlevel': 0,
+ 'print_hide': None,
+ 'report_hide': None,
+ 'reqd': None,
+ 'search_index': None,
+ 'trigger': None,
+ 'width': None
+ },
+ {
+ 'allow_on_submit': None,
+ 'colour': 'White:FFF',
+ 'creation': '2011-05-25 12:59:30',
+ 'default': None,
+ 'depends_on': None,
+ 'description': '<em>e.g. Office, Billing, Shipping</em>',
+ 'docstatus': 0,
+ 'doctype': 'DocField',
+ 'fieldname': 'address_type',
+ 'fieldtype': 'Data',
+ 'hidden': None,
+ 'icon': None,
+ 'idx': 2,
+ 'in_filter': None,
+ 'label': 'Address Type',
+ 'modified': '2011-05-26 17:45:25',
+ 'modified_by': 'Administrator',
+ 'name': 'FL05073',
+ 'no_column': None,
+ 'no_copy': None,
+ 'oldfieldname': None,
+ 'oldfieldtype': None,
+ 'options': None,
+ 'owner': 'Administrator',
+ 'parent': 'Address',
+ 'parentfield': 'fields',
+ 'parenttype': 'DocType',
+ 'permlevel': 0,
+ 'print_hide': None,
+ 'report_hide': None,
+ 'reqd': 1,
+ 'search_index': None,
+ 'trigger': None,
+ 'width': None
+ },
+ {
+ 'allow_on_submit': None,
+ 'colour': 'White:FFF',
+ 'creation': '2011-05-25 12:59:30',
+ 'default': None,
+ 'depends_on': None,
+ 'description': None,
+ 'docstatus': 0,
+ 'doctype': 'DocField',
+ 'fieldname': 'address_line1',
+ 'fieldtype': 'Data',
+ 'hidden': None,
+ 'icon': None,
+ 'idx': 3,
+ 'in_filter': None,
+ 'label': 'Address Line1',
+ 'modified': '2011-05-26 17:45:25',
+ 'modified_by': 'Administrator',
+ 'name': 'FL05074',
+ 'no_column': None,
+ 'no_copy': None,
+ 'oldfieldname': None,
+ 'oldfieldtype': None,
+ 'options': None,
+ 'owner': 'Administrator',
+ 'parent': 'Address',
+ 'parentfield': 'fields',
+ 'parenttype': 'DocType',
+ 'permlevel': 0,
+ 'print_hide': None,
+ 'report_hide': None,
+ 'reqd': 1,
+ 'search_index': None,
+ 'trigger': None,
+ 'width': None
+ },
+ {
+ 'allow_on_submit': None,
+ 'colour': None,
+ 'creation': '2011-05-25 12:59:30',
+ 'default': None,
+ 'depends_on': None,
+ 'description': None,
+ 'docstatus': 0,
+ 'doctype': 'DocField',
+ 'fieldname': 'address_line2',
+ 'fieldtype': 'Data',
+ 'hidden': None,
+ 'icon': None,
+ 'idx': 4,
+ 'in_filter': None,
+ 'label': 'Address Line2',
+ 'modified': '2011-05-26 17:45:25',
+ 'modified_by': 'Administrator',
+ 'name': 'FL05075',
+ 'no_column': None,
+ 'no_copy': None,
+ 'oldfieldname': None,
+ 'oldfieldtype': None,
+ 'options': None,
+ 'owner': 'Administrator',
+ 'parent': 'Address',
+ 'parentfield': 'fields',
+ 'parenttype': 'DocType',
+ 'permlevel': 0,
+ 'print_hide': None,
+ 'report_hide': None,
+ 'reqd': None,
+ 'search_index': None,
+ 'trigger': None,
+ 'width': None
+ },
+ {
+ 'allow_on_submit': None,
+ 'colour': 'White:FFF',
+ 'creation': '2011-05-25 12:59:30',
+ 'default': None,
+ 'depends_on': None,
+ 'description': None,
+ 'docstatus': 0,
+ 'doctype': 'DocField',
+ 'fieldname': 'city',
+ 'fieldtype': 'Data',
+ 'hidden': None,
+ 'icon': None,
+ 'idx': 5,
+ 'in_filter': 1,
+ 'label': 'City/Town',
+ 'modified': '2011-05-26 17:45:25',
+ 'modified_by': 'Administrator',
+ 'name': 'FL05076',
+ 'no_column': None,
+ 'no_copy': None,
+ 'oldfieldname': None,
+ 'oldfieldtype': None,
+ 'options': 'Suggest',
+ 'owner': 'Administrator',
+ 'parent': 'Address',
+ 'parentfield': 'fields',
+ 'parenttype': 'DocType',
+ 'permlevel': 0,
+ 'print_hide': None,
+ 'report_hide': None,
+ 'reqd': 1,
+ 'search_index': 1,
+ 'trigger': None,
+ 'width': None
+ },
+ {
+ 'allow_on_submit': None,
+ 'colour': None,
+ 'creation': '2011-05-25 12:59:30',
+ 'default': None,
+ 'depends_on': None,
+ 'description': None,
+ 'docstatus': 0,
+ 'doctype': 'DocField',
+ 'fieldname': 'pincode',
+ 'fieldtype': 'Data',
+ 'hidden': None,
+ 'icon': None,
+ 'idx': 6,
+ 'in_filter': 1,
+ 'label': 'Pincode',
+ 'modified': '2011-05-26 17:45:25',
+ 'modified_by': 'Administrator',
+ 'name': 'FL05077',
+ 'no_column': None,
+ 'no_copy': None,
+ 'oldfieldname': None,
+ 'oldfieldtype': None,
+ 'options': None,
+ 'owner': 'Administrator',
+ 'parent': 'Address',
+ 'parentfield': 'fields',
+ 'parenttype': 'DocType',
+ 'permlevel': 0,
+ 'print_hide': None,
+ 'report_hide': None,
+ 'reqd': None,
+ 'search_index': 1,
+ 'trigger': None,
+ 'width': None
+ },
+ {
+ 'allow_on_submit': None,
+ 'colour': 'White:FFF',
+ 'creation': '2011-05-25 12:59:30',
+ 'default': None,
+ 'depends_on': None,
+ 'description': None,
+ 'docstatus': 0,
+ 'doctype': 'DocField',
+ 'fieldname': 'country',
+ 'fieldtype': 'Select',
+ 'hidden': None,
+ 'icon': None,
+ 'idx': 7,
+ 'in_filter': 1,
+ 'label': 'Country',
+ 'modified': '2011-05-26 17:45:25',
+ 'modified_by': 'Administrator',
+ 'name': 'FL05078',
+ 'no_column': None,
+ 'no_copy': None,
+ 'oldfieldname': None,
+ 'oldfieldtype': None,
+ 'options': 'link:Country',
+ 'owner': 'Administrator',
+ 'parent': 'Address',
+ 'parentfield': 'fields',
+ 'parenttype': 'DocType',
+ 'permlevel': 0,
+ 'print_hide': None,
+ 'report_hide': None,
+ 'reqd': 1,
+ 'search_index': 1,
+ 'trigger': 'Client',
+ 'width': None
+ },
+ {
+ 'allow_on_submit': None,
+ 'colour': 'White:FFF',
+ 'creation': '2011-05-25 12:59:30',
+ 'default': None,
+ 'depends_on': None,
+ 'description': None,
+ 'docstatus': 0,
+ 'doctype': 'DocField',
+ 'fieldname': 'state',
+ 'fieldtype': 'Data',
+ 'hidden': None,
+ 'icon': None,
+ 'idx': 8,
+ 'in_filter': 1,
+ 'label': 'State',
+ 'modified': '2011-05-26 17:45:25',
+ 'modified_by': 'Administrator',
+ 'name': 'FL05079',
+ 'no_column': None,
+ 'no_copy': None,
+ 'oldfieldname': None,
+ 'oldfieldtype': None,
+ 'options': 'Suggest',
+ 'owner': 'Administrator',
+ 'parent': 'Address',
+ 'parentfield': 'fields',
+ 'parenttype': 'DocType',
+ 'permlevel': 0,
+ 'print_hide': None,
+ 'report_hide': None,
+ 'reqd': None,
+ 'search_index': 0,
+ 'trigger': None,
+ 'width': None
+ },
+ {
+ 'allow_on_submit': None,
+ 'colour': None,
+ 'creation': '2011-05-25 12:59:30',
+ 'default': None,
+ 'depends_on': None,
+ 'description': None,
+ 'docstatus': 0,
+ 'doctype': 'DocField',
+ 'fieldname': None,
+ 'fieldtype': 'Column Break',
+ 'hidden': None,
+ 'icon': None,
+ 'idx': 9,
+ 'in_filter': None,
+ 'label': None,
+ 'modified': '2011-05-26 17:45:25',
+ 'modified_by': 'Administrator',
+ 'name': 'FL05080',
+ 'no_column': None,
+ 'no_copy': None,
+ 'oldfieldname': None,
+ 'oldfieldtype': None,
+ 'options': None,
+ 'owner': 'Administrator',
+ 'parent': 'Address',
+ 'parentfield': 'fields',
+ 'parenttype': 'DocType',
+ 'permlevel': 0,
+ 'print_hide': 0,
+ 'report_hide': None,
+ 'reqd': None,
+ 'search_index': None,
+ 'trigger': None,
+ 'width': '50%'
+ },
+ {
+ 'allow_on_submit': None,
+ 'colour': None,
+ 'creation': '2011-05-25 12:59:30',
+ 'default': None,
+ 'depends_on': None,
+ 'description': None,
+ 'docstatus': 0,
+ 'doctype': 'DocField',
+ 'fieldname': 'phone',
+ 'fieldtype': 'Data',
+ 'hidden': None,
+ 'icon': None,
+ 'idx': 10,
+ 'in_filter': None,
+ 'label': 'Phone',
+ 'modified': '2011-05-26 17:45:25',
+ 'modified_by': 'Administrator',
+ 'name': 'FL05081',
+ 'no_column': None,
+ 'no_copy': None,
+ 'oldfieldname': None,
+ 'oldfieldtype': None,
+ 'options': None,
+ 'owner': 'Administrator',
+ 'parent': 'Address',
+ 'parentfield': 'fields',
+ 'parenttype': 'DocType',
+ 'permlevel': 0,
+ 'print_hide': None,
+ 'report_hide': None,
+ 'reqd': 1,
+ 'search_index': None,
+ 'trigger': None,
+ 'width': None
+ },
+ {
+ 'allow_on_submit': None,
+ 'colour': None,
+ 'creation': '2011-05-25 12:59:30',
+ 'default': None,
+ 'depends_on': None,
+ 'description': None,
+ 'docstatus': 0,
+ 'doctype': 'DocField',
+ 'fieldname': 'email_id',
+ 'fieldtype': 'Data',
+ 'hidden': None,
+ 'icon': None,
+ 'idx': 11,
+ 'in_filter': None,
+ 'label': 'Email Id',
+ 'modified': '2011-05-26 17:45:25',
+ 'modified_by': 'Administrator',
+ 'name': 'FL05082',
+ 'no_column': None,
+ 'no_copy': None,
+ 'oldfieldname': None,
+ 'oldfieldtype': None,
+ 'options': None,
+ 'owner': 'Administrator',
+ 'parent': 'Address',
+ 'parentfield': 'fields',
+ 'parenttype': 'DocType',
+ 'permlevel': 0,
+ 'print_hide': None,
+ 'report_hide': None,
+ 'reqd': None,
+ 'search_index': None,
+ 'trigger': None,
+ 'width': None
+ },
+ {
+ 'allow_on_submit': None,
+ 'colour': None,
+ 'creation': '2011-05-25 12:59:30',
+ 'default': None,
+ 'depends_on': None,
+ 'description': None,
+ 'docstatus': 0,
+ 'doctype': 'DocField',
+ 'fieldname': 'fax',
+ 'fieldtype': 'Data',
+ 'hidden': None,
+ 'icon': None,
+ 'idx': 12,
+ 'in_filter': None,
+ 'label': 'Fax',
+ 'modified': '2011-05-26 17:45:25',
+ 'modified_by': 'Administrator',
+ 'name': 'FL05083',
+ 'no_column': None,
+ 'no_copy': None,
+ 'oldfieldname': None,
+ 'oldfieldtype': None,
+ 'options': None,
+ 'owner': 'Administrator',
+ 'parent': 'Address',
+ 'parentfield': 'fields',
+ 'parenttype': 'DocType',
+ 'permlevel': 0,
+ 'print_hide': None,
+ 'report_hide': None,
+ 'reqd': None,
+ 'search_index': None,
+ 'trigger': None,
+ 'width': None
+ },
+ {
+ 'allow_on_submit': None,
+ 'colour': 'White:FFF',
+ 'creation': '2011-05-25 12:59:30',
+ 'default': None,
+ 'depends_on': 'eval:!doc.supplier && !doc.sales_partner',
+ 'description': None,
+ 'docstatus': 0,
+ 'doctype': 'DocField',
+ 'fieldname': 'customer',
+ 'fieldtype': 'Link',
+ 'hidden': None,
+ 'icon': None,
+ 'idx': 13,
+ 'in_filter': None,
+ 'label': 'Customer',
+ 'modified': '2011-05-26 17:45:25',
+ 'modified_by': 'Administrator',
+ 'name': 'FL05084',
+ 'no_column': None,
+ 'no_copy': None,
+ 'oldfieldname': None,
+ 'oldfieldtype': None,
+ 'options': 'Customer',
+ 'owner': 'Administrator',
+ 'parent': 'Address',
+ 'parentfield': 'fields',
+ 'parenttype': 'DocType',
+ 'permlevel': 0,
+ 'print_hide': None,
+ 'report_hide': None,
+ 'reqd': None,
+ 'search_index': None,
+ 'trigger': None,
+ 'width': None
+ },
+ {
+ 'allow_on_submit': None,
+ 'colour': 'White:FFF',
+ 'creation': '2011-05-25 12:59:31',
+ 'default': None,
+ 'depends_on': 'eval:!doc.supplier && !doc.sales_partner',
+ 'description': None,
+ 'docstatus': 0,
+ 'doctype': 'DocField',
+ 'fieldname': 'customer_name',
+ 'fieldtype': 'Data',
+ 'hidden': None,
+ 'icon': None,
+ 'idx': 14,
+ 'in_filter': None,
+ 'label': 'Customer Name',
+ 'modified': '2011-05-26 17:45:25',
+ 'modified_by': 'Administrator',
+ 'name': 'FL05085',
+ 'no_column': None,
+ 'no_copy': None,
+ 'oldfieldname': None,
+ 'oldfieldtype': None,
+ 'options': None,
+ 'owner': 'Administrator',
+ 'parent': 'Address',
+ 'parentfield': 'fields',
+ 'parenttype': 'DocType',
+ 'permlevel': 1,
+ 'print_hide': None,
+ 'report_hide': None,
+ 'reqd': None,
+ 'search_index': None,
+ 'trigger': None,
+ 'width': None
+ },
+ {
+ 'allow_on_submit': None,
+ 'colour': 'White:FFF',
+ 'creation': '2011-05-25 12:59:31',
+ 'default': None,
+ 'depends_on': 'eval:!doc.customer && !doc.sales_partner',
+ 'description': None,
+ 'docstatus': 0,
+ 'doctype': 'DocField',
+ 'fieldname': 'supplier',
+ 'fieldtype': 'Link',
+ 'hidden': None,
+ 'icon': None,
+ 'idx': 15,
+ 'in_filter': None,
+ 'label': 'Supplier',
+ 'modified': '2011-05-26 17:45:25',
+ 'modified_by': 'Administrator',
+ 'name': 'FL05086',
+ 'no_column': None,
+ 'no_copy': None,
+ 'oldfieldname': None,
+ 'oldfieldtype': None,
+ 'options': 'Supplier',
+ 'owner': 'Administrator',
+ 'parent': 'Address',
+ 'parentfield': 'fields',
+ 'parenttype': 'DocType',
+ 'permlevel': 0,
+ 'print_hide': None,
+ 'report_hide': None,
+ 'reqd': None,
+ 'search_index': None,
+ 'trigger': None,
+ 'width': None
+ },
+ {
+ 'allow_on_submit': None,
+ 'colour': 'White:FFF',
+ 'creation': '2011-05-25 12:59:31',
+ 'default': None,
+ 'depends_on': 'eval:!doc.customer && !doc.sales_partner',
+ 'description': None,
+ 'docstatus': 0,
+ 'doctype': 'DocField',
+ 'fieldname': 'supplier_name',
+ 'fieldtype': 'Data',
+ 'hidden': None,
+ 'icon': None,
+ 'idx': 16,
+ 'in_filter': None,
+ 'label': 'Supplier Name',
+ 'modified': '2011-05-26 17:45:25',
+ 'modified_by': 'Administrator',
+ 'name': 'FL05087',
+ 'no_column': None,
+ 'no_copy': None,
+ 'oldfieldname': None,
+ 'oldfieldtype': None,
+ 'options': None,
+ 'owner': 'Administrator',
+ 'parent': 'Address',
+ 'parentfield': 'fields',
+ 'parenttype': 'DocType',
+ 'permlevel': 1,
+ 'print_hide': None,
+ 'report_hide': None,
+ 'reqd': None,
+ 'search_index': None,
+ 'trigger': None,
+ 'width': None
+ },
+ {
+ 'allow_on_submit': None,
+ 'colour': 'White:FFF',
+ 'creation': '2011-05-25 12:59:31',
+ 'default': None,
+ 'depends_on': 'eval:!doc.customer && !doc.supplier',
+ 'description': None,
+ 'docstatus': 0,
+ 'doctype': 'DocField',
+ 'fieldname': 'sales_partner',
+ 'fieldtype': 'Link',
+ 'hidden': None,
+ 'icon': None,
+ 'idx': 17,
+ 'in_filter': None,
+ 'label': 'Sales Partner',
+ 'modified': '2011-05-26 17:45:25',
+ 'modified_by': 'Administrator',
+ 'name': 'FL05088',
+ 'no_column': None,
+ 'no_copy': None,
+ 'oldfieldname': None,
+ 'oldfieldtype': None,
+ 'options': 'Sales Partner',
+ 'owner': 'Administrator',
+ 'parent': 'Address',
+ 'parentfield': 'fields',
+ 'parenttype': 'DocType',
+ 'permlevel': 0,
+ 'print_hide': None,
+ 'report_hide': None,
+ 'reqd': None,
+ 'search_index': None,
+ 'trigger': None,
+ 'width': None
+ },
+ {
+ 'allow_on_submit': None,
+ 'colour': 'White:FFF',
+ 'creation': '2011-05-25 12:59:31',
+ 'default': '0',
+ 'depends_on': None,
+ 'description': 'Check to make primary address',
+ 'docstatus': 0,
+ 'doctype': 'DocField',
+ 'fieldname': 'is_primary_address',
+ 'fieldtype': 'Check',
+ 'hidden': None,
+ 'icon': None,
+ 'idx': 18,
+ 'in_filter': None,
+ 'label': 'Is Primary Address',
+ 'modified': '2011-05-26 17:45:25',
+ 'modified_by': 'Administrator',
+ 'name': 'FL05089',
+ 'no_column': None,
+ 'no_copy': None,
+ 'oldfieldname': None,
+ 'oldfieldtype': None,
+ 'options': None,
+ 'owner': 'Administrator',
+ 'parent': 'Address',
+ 'parentfield': 'fields',
+ 'parenttype': 'DocType',
+ 'permlevel': 0,
+ 'print_hide': None,
+ 'report_hide': None,
+ 'reqd': None,
+ 'search_index': None,
+ 'trigger': None,
+ 'width': None
+ },
+ {
+ 'allow_on_submit': None,
+ 'colour': 'White:FFF',
+ 'creation': '2011-05-25 12:59:31',
+ 'default': '0',
+ 'depends_on': None,
+ 'description': 'Check to make Shipping Address',
+ 'docstatus': 0,
+ 'doctype': 'DocField',
+ 'fieldname': 'is_shipping_address',
+ 'fieldtype': 'Check',
+ 'hidden': None,
+ 'icon': None,
+ 'idx': 19,
+ 'in_filter': None,
+ 'label': 'Is Shipping Address',
+ 'modified': '2011-05-26 17:45:25',
+ 'modified_by': 'Administrator',
+ 'name': 'FL05090',
+ 'no_column': None,
+ 'no_copy': None,
+ 'oldfieldname': None,
+ 'oldfieldtype': None,
+ 'options': None,
+ 'owner': 'Administrator',
+ 'parent': 'Address',
+ 'parentfield': 'fields',
+ 'parenttype': 'DocType',
+ 'permlevel': 0,
+ 'print_hide': None,
+ 'report_hide': None,
+ 'reqd': None,
+ 'search_index': None,
+ 'trigger': None,
+ 'width': None
+ },
+ {
+ 'allow_on_submit': None,
+ 'colour': None,
+ 'creation': '2011-05-25 12:59:31',
+ 'default': None,
+ 'depends_on': None,
+ 'description': None,
+ 'docstatus': 0,
+ 'doctype': 'DocField',
+ 'fieldname': 'trash_reason',
+ 'fieldtype': 'Small Text',
+ 'hidden': None,
+ 'icon': None,
+ 'idx': 20,
+ 'in_filter': None,
+ 'label': 'Trash Reason',
+ 'modified': '2011-05-26 17:45:25',
+ 'modified_by': 'Administrator',
+ 'name': 'FL05091',
+ 'no_column': None,
+ 'no_copy': None,
+ 'oldfieldname': None,
+ 'oldfieldtype': None,
+ 'options': None,
+ 'owner': 'Administrator',
+ 'parent': 'Address',
+ 'parentfield': 'fields',
+ 'parenttype': 'DocType',
+ 'permlevel': 0,
+ 'print_hide': None,
+ 'report_hide': None,
+ 'reqd': None,
+ 'search_index': None,
+ 'trigger': None,
+ 'width': None
+ }
+]
\ No newline at end of file
diff --git a/tools/doctype/business_letter/__init__.py b/tools/doctype/business_letter/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tools/doctype/business_letter/__init__.py
diff --git a/tools/doctype/business_letter/business_letter.js b/tools/doctype/business_letter/business_letter.js
new file mode 100644
index 0000000..35abc0f
--- /dev/null
+++ b/tools/doctype/business_letter/business_letter.js
@@ -0,0 +1,38 @@
+$import(Tips Common)
+
+cur_frm.fields_dict['template'].get_query=function(doc,cdt,cdn){
+ return "SELECT `tabBusiness Letter Template`.name FROM `tabBusiness Letter Template` WHERE `tabBusiness Letter Template`.letter_type='"+doc.letter_type+"' AND `tabBusiness Letter Template`.name like '%s' LIMIT 50"
+}
+
+cur_frm.cscript.template = function(doc,cdt,cdn){
+ //set title as like template
+ doc.title = doc.template;
+ refresh_field('title');
+
+ //set print heading as title
+ cur_frm.pformat.print_heading=doc.title;
+ cur_frm.pformat.print_subheading = ' ';
+
+ //call set_content function to pull content as per template selected
+ $c_obj([doc], 'set_content', '',function(r, rt) { refresh_field('content');});
+}
+
+cur_frm.cscript.title= function(doc,cdt,cdn){
+ //set print heading on title change
+ cur_frm.pformat.print_heading=doc.title;
+ cur_frm.pformat.print_subheading = ' ';
+}
+
+cur_frm.cscript.refresh= function(doc,cdt,cdn){
+ cur_frm.cscript.get_tips(doc, cdt, cdn);
+ //set print heading on refresh
+ cur_frm.pformat.print_heading=doc.title;
+ cur_frm.pformat.print_subheading = ' ';
+}
+
+cur_frm.cscript.onload= function(doc,cdt,cdn){
+ cur_frm.cscript.get_tips(doc, cdt, cdn);
+ //set print heading
+ cur_frm.pformat.print_heading=doc.title;
+ cur_frm.pformat.print_subheading = ' ';
+}
diff --git a/tools/doctype/business_letter/business_letter.py b/tools/doctype/business_letter/business_letter.py
new file mode 100644
index 0000000..47de45c
--- /dev/null
+++ b/tools/doctype/business_letter/business_letter.py
@@ -0,0 +1,29 @@
+# Please edit this list and import only required elements
+import webnotes
+
+from webnotes.utils import add_days, add_months, add_years, cint, cstr, date_diff, default_fields, flt, fmt_money, formatdate, generate_hash, getTraceback, get_defaults, get_first_day, get_last_day, getdate, has_common, month_name, now, nowdate, replace_newlines, sendmail, set_default, str_esc_quote, user_format, validate_email_add
+from webnotes.model import db_exists
+from webnotes.model.doc import Document, addchild, removechild, getchildren, make_autoname, SuperDocType
+from webnotes.model.doclist import getlist, copy_doclist
+from webnotes.model.code import get_obj, get_server_obj, run_server_obj, updatedb, check_syntax
+from webnotes import session, form, is_testing, msgprint, errprint
+
+set = webnotes.conn.set
+sql = webnotes.conn.sql
+get_value = webnotes.conn.get_value
+in_transaction = webnotes.conn.in_transaction
+convert_to_lists = webnotes.conn.convert_to_lists
+
+# -----------------------------------------------------------------------------------------
+
+
+class DocType:
+ #init function
+ def __init__(self,doc,doclist=[]):
+ self.doc = doc
+ self.doclist = doclist
+
+ def set_content(self):
+ ret_content = sql("select content from `tabBusiness Letter Template` where name ='%s'"%self.doc.template)
+ if ret_content: self.doc.content = ret_content[0][0]
+ return ''
\ No newline at end of file
diff --git a/tools/doctype/business_letter/business_letter.txt b/tools/doctype/business_letter/business_letter.txt
new file mode 100644
index 0000000..7be0aba
--- /dev/null
+++ b/tools/doctype/business_letter/business_letter.txt
@@ -0,0 +1 @@
+[{'section_style': 'Simple', 'is_transaction_doc': None, 'creation': '2010-04-20 11:10:52', 'search_fields': None, 'module': 'Tools', 'doctype': 'DocType', 'change_log': None, 'print_outline': '', 'owner': 'harshada@webnotestech.com', 'in_dialog': None, 'in_create': None, 'read_only': None, 'allow_email': None, 'dt_template': None, 'hide_heading': None, 'issingle': None, 'allow_rename': None, 'smallicon': None, 'allow_attach': None, 'show_in_menu': None, 'max_attachments': None, 'version': 12, 'menu_index': None, 'docstatus': 0, 'allow_copy': None, 'istable': None, 'description': None, 'parent': None, 'server_code': None, 'allow_trash': None, 'allow_print': None, 'autoname': 'Letter/.####', 'client_script_core': None, 'client_string': None, 'use_template': None, 'modified_by': 'harshada@webnotestech.com', 'document_type': 'Master', 'name': 'Business Letter', 'idx': None, 'hide_toolbar': None, 'colour': 'White:FFF', 'client_script': None, 'modified': '2010-10-22 10:37:10', 'server_code_error': ' ', 'name_case': '', 'parenttype': None, 'read_only_onload': 1, 'server_code_core': None, 'server_code_compiled': None, 'parent_node': None, 'parentfield': None}, {'cancel': None, 'amend': None, 'execute': None, 'modified_by': 'harshada@webnotestech.com', 'name': 'PERM00843', 'parent': 'Business Letter', 'read': 1, 'create': 1, 'creation': '2010-04-20 11:10:52', 'modified': '2010-10-22 10:37:10', 'submit': None, 'doctype': 'DocPerm', 'write': 1, 'idx': 1, 'parenttype': 'DocType', 'role': 'All', 'owner': 'harshada@webnotestech.com', 'docstatus': 0, 'permlevel': 0, 'match': 'owner', 'parentfield': 'permissions'}, {'cancel': None, 'amend': None, 'execute': None, 'modified_by': 'harshada@webnotestech.com', 'name': 'PERM00844', 'parent': 'Business Letter', 'read': 1, 'create': 1, 'creation': '2010-04-20 11:10:52', 'modified': '2010-10-22 10:37:10', 'submit': None, 'doctype': 'DocPerm', 'write': 1, 'idx': 2, 'parenttype': 'DocType', 'role': 'System Manager', 'owner': 'harshada@webnotestech.com', 'docstatus': 0, 'permlevel': 0, 'match': None, 'parentfield': 'permissions'}, {'no_copy': None, 'oldfieldtype': 'Select', 'creation': '2010-04-20 11:10:52', 'doctype': 'DocField', 'oldfieldname': 'letter_type', 'owner': 'harshada@webnotestech.com', 'reqd': 0, 'in_filter': None, 'print_hide': 1, 'modified_by': 'harshada@webnotestech.com', 'label': 'Letter Type', 'width': None, 'trigger': '', 'depends_on': None, 'docstatus': 0, 'hidden': None, 'permlevel': 0, 'description': None, 'parent': 'Business Letter', 'search_index': None, 'allow_on_submit': None, 'icon': None, 'name': 'FL04796', 'idx': 1, 'default': None, 'colour': 'White:FFF', 'modified': '2010-10-22 10:37:10', 'parenttype': 'DocType', 'fieldname': 'letter_type', 'fieldtype': 'Select', 'options': 'link:Business Letter Type', 'report_hide': None, 'parentfield': 'fields'}, {'no_copy': None, 'oldfieldtype': 'Link', 'creation': '2010-04-20 11:10:52', 'doctype': 'DocField', 'oldfieldname': 'template', 'owner': 'harshada@webnotestech.com', 'reqd': None, 'in_filter': None, 'print_hide': 1, 'modified_by': 'harshada@webnotestech.com', 'label': 'Template', 'width': None, 'trigger': 'Client', 'depends_on': None, 'docstatus': 0, 'hidden': None, 'permlevel': 0, 'description': None, 'parent': 'Business Letter', 'search_index': None, 'allow_on_submit': None, 'icon': None, 'name': 'FL04797', 'idx': 2, 'default': None, 'colour': 'White:FFF', 'modified': '2010-10-22 10:37:10', 'parenttype': 'DocType', 'fieldname': 'template', 'fieldtype': 'Link', 'options': 'Business Letter Template', 'report_hide': None, 'parentfield': 'fields'}, {'no_copy': None, 'oldfieldtype': 'Link', 'creation': '2010-04-20 11:10:52', 'doctype': 'DocField', 'oldfieldname': 'to_contact', 'owner': 'harshada@webnotestech.com', 'reqd': 1, 'in_filter': None, 'print_hide': 1, 'modified_by': 'harshada@webnotestech.com', 'label': 'To Contact', 'width': None, 'trigger': None, 'depends_on': None, 'docstatus': 0, 'hidden': None, 'permlevel': 0, 'description': None, 'parent': 'Business Letter', 'search_index': None, 'allow_on_submit': None, 'icon': None, 'name': 'FL04798', 'idx': 3, 'default': None, 'colour': None, 'modified': '2010-10-22 10:37:10', 'parenttype': 'DocType', 'fieldname': 'to_contact', 'fieldtype': 'Link', 'options': 'Contact', 'report_hide': None, 'parentfield': 'fields'}, {'no_copy': None, 'oldfieldtype': 'Data', 'creation': '2010-04-20 11:42:39', 'doctype': 'DocField', 'oldfieldname': 'title', 'owner': 'harshada@webnotestech.com', 'reqd': 1, 'in_filter': None, 'print_hide': 1, 'modified_by': 'harshada@webnotestech.com', 'label': 'Title', 'width': None, 'trigger': None, 'depends_on': None, 'docstatus': 0, 'hidden': None, 'permlevel': 0, 'description': None, 'parent': 'Business Letter', 'search_index': None, 'allow_on_submit': None, 'icon': None, 'name': 'FL04800', 'idx': 4, 'default': None, 'colour': None, 'modified': '2010-10-22 10:37:10', 'parenttype': 'DocType', 'fieldname': 'title', 'fieldtype': 'Data', 'options': None, 'report_hide': None, 'parentfield': 'fields'}, {'no_copy': None, 'oldfieldtype': 'Text Editor', 'creation': '2010-04-20 11:10:52', 'doctype': 'DocField', 'oldfieldname': 'content', 'owner': 'harshada@webnotestech.com', 'reqd': 1, 'in_filter': None, 'print_hide': None, 'modified_by': 'harshada@webnotestech.com', 'label': 'Content', 'width': None, 'trigger': None, 'depends_on': None, 'docstatus': 0, 'hidden': None, 'permlevel': 0, 'description': None, 'parent': 'Business Letter', 'search_index': None, 'allow_on_submit': None, 'icon': None, 'name': 'FL04799', 'idx': 5, 'default': None, 'colour': None, 'modified': '2010-10-22 10:37:10', 'parenttype': 'DocType', 'fieldname': 'content', 'fieldtype': 'Text Editor', 'options': None, 'report_hide': None, 'parentfield': 'fields'}]
\ No newline at end of file
diff --git a/tools/doctype/business_letter_template/__init__.py b/tools/doctype/business_letter_template/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tools/doctype/business_letter_template/__init__.py
diff --git a/tools/doctype/business_letter_template/business_letter_template.js b/tools/doctype/business_letter_template/business_letter_template.js
new file mode 100644
index 0000000..fe1457d
--- /dev/null
+++ b/tools/doctype/business_letter_template/business_letter_template.js
@@ -0,0 +1,10 @@
+$import(Tips Common)
+
+//--------- ONLOAD -------------
+cur_frm.cscript.onload = function(doc, cdt, cdn) {
+ cur_frm.cscript.get_tips(doc, cdt, cdn);
+}
+
+cur_frm.cscript.refresh = function(doc, cdt, cdn) {
+ cur_frm.cscript.get_tips(doc, cdt, cdn);
+}
\ No newline at end of file
diff --git a/tools/doctype/business_letter_template/business_letter_template.txt b/tools/doctype/business_letter_template/business_letter_template.txt
new file mode 100644
index 0000000..90af060
--- /dev/null
+++ b/tools/doctype/business_letter_template/business_letter_template.txt
@@ -0,0 +1 @@
+[{'section_style': 'Simple', 'is_transaction_doc': None, 'creation': '2010-04-20 11:06:16', 'search_fields': None, 'module': 'Tools', 'doctype': 'DocType', 'change_log': None, 'print_outline': '', 'owner': 'harshada@webnotestech.com', 'in_dialog': None, 'in_create': None, 'read_only': None, 'allow_email': None, 'dt_template': None, 'hide_heading': None, 'issingle': None, 'allow_rename': None, 'smallicon': None, 'allow_attach': None, 'show_in_menu': None, 'max_attachments': None, 'version': 3, 'menu_index': None, 'docstatus': 0, 'allow_copy': None, 'istable': None, 'description': None, 'parent': None, 'server_code': None, 'allow_trash': None, 'allow_print': None, 'autoname': 'field:title', 'client_script_core': None, 'client_string': None, 'use_template': None, 'modified_by': 'ashwini@webnotestech.com', 'document_type': 'Master', 'name': 'Business Letter Template', 'idx': None, 'hide_toolbar': None, 'colour': 'White:FFF', 'client_script': None, 'modified': '2010-09-20 14:06:57', 'server_code_error': ' ', 'name_case': '', 'parenttype': None, 'read_only_onload': None, 'server_code_core': None, 'server_code_compiled': None, 'parent_node': None, 'parentfield': None}, {'cancel': None, 'amend': None, 'execute': None, 'modified_by': 'ashwini@webnotestech.com', 'name': 'PERM00840', 'parent': 'Business Letter Template', 'read': 1, 'create': 1, 'creation': '2010-04-20 11:06:16', 'modified': '2010-09-20 09:03:29', 'submit': None, 'doctype': 'DocPerm', 'write': 1, 'idx': 1, 'parenttype': 'DocType', 'role': 'System Manager', 'owner': 'harshada@webnotestech.com', 'docstatus': 0, 'permlevel': 0, 'match': None, 'parentfield': 'permissions'}, {'cancel': None, 'amend': None, 'execute': None, 'modified_by': 'ashwini@webnotestech.com', 'name': 'PERM00841', 'parent': 'Business Letter Template', 'read': 1, 'create': None, 'creation': '2010-04-20 11:06:16', 'modified': '2010-09-20 09:03:29', 'submit': None, 'doctype': 'DocPerm', 'write': None, 'idx': 2, 'parenttype': 'DocType', 'role': 'All', 'owner': 'harshada@webnotestech.com', 'docstatus': 0, 'permlevel': 0, 'match': None, 'parentfield': 'permissions'}, {'no_copy': None, 'oldfieldtype': 'Data', 'creation': '2010-04-20 11:06:16', 'doctype': 'DocField', 'oldfieldname': 'title', 'owner': 'harshada@webnotestech.com', 'reqd': 1, 'in_filter': None, 'print_hide': None, 'modified_by': 'ashwini@webnotestech.com', 'label': 'Title', 'width': None, 'trigger': None, 'depends_on': None, 'docstatus': 0, 'hidden': None, 'permlevel': 0, 'description': None, 'parent': 'Business Letter Template', 'search_index': None, 'allow_on_submit': None, 'icon': None, 'name': 'FL04792', 'idx': 1, 'default': None, 'colour': None, 'modified': '2010-09-20 09:03:29', 'parenttype': 'DocType', 'fieldname': 'title', 'fieldtype': 'Data', 'options': None, 'report_hide': None, 'parentfield': 'fields'}, {'no_copy': None, 'oldfieldtype': 'Link', 'creation': '2010-04-20 11:06:16', 'doctype': 'DocField', 'oldfieldname': 'letter_type', 'owner': 'harshada@webnotestech.com', 'reqd': 1, 'in_filter': None, 'print_hide': None, 'modified_by': 'ashwini@webnotestech.com', 'label': 'Letter Type', 'width': None, 'trigger': None, 'depends_on': None, 'docstatus': 0, 'hidden': None, 'permlevel': 0, 'description': None, 'parent': 'Business Letter Template', 'search_index': None, 'allow_on_submit': None, 'icon': None, 'name': 'FL04794', 'idx': 2, 'default': None, 'colour': None, 'modified': '2010-09-20 09:03:29', 'parenttype': 'DocType', 'fieldname': 'letter_type', 'fieldtype': 'Link', 'options': 'Business Letter Type', 'report_hide': None, 'parentfield': 'fields'}, {'no_copy': None, 'oldfieldtype': 'Text Editor', 'creation': '2010-04-20 11:06:16', 'doctype': 'DocField', 'oldfieldname': 'content', 'owner': 'harshada@webnotestech.com', 'reqd': 1, 'in_filter': None, 'print_hide': None, 'modified_by': 'ashwini@webnotestech.com', 'label': 'Content', 'width': None, 'trigger': None, 'depends_on': None, 'docstatus': 0, 'hidden': None, 'permlevel': 0, 'description': None, 'parent': 'Business Letter Template', 'search_index': None, 'allow_on_submit': None, 'icon': None, 'name': 'FL04793', 'idx': 3, 'default': None, 'colour': None, 'modified': '2010-09-20 09:03:29', 'parenttype': 'DocType', 'fieldname': 'content', 'fieldtype': 'Text Editor', 'options': None, 'report_hide': None, 'parentfield': 'fields'}]
\ No newline at end of file
diff --git a/tools/doctype/business_letter_type/__init__.py b/tools/doctype/business_letter_type/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tools/doctype/business_letter_type/__init__.py
diff --git a/tools/doctype/business_letter_type/business_letter_type.js b/tools/doctype/business_letter_type/business_letter_type.js
new file mode 100644
index 0000000..fe1457d
--- /dev/null
+++ b/tools/doctype/business_letter_type/business_letter_type.js
@@ -0,0 +1,10 @@
+$import(Tips Common)
+
+//--------- ONLOAD -------------
+cur_frm.cscript.onload = function(doc, cdt, cdn) {
+ cur_frm.cscript.get_tips(doc, cdt, cdn);
+}
+
+cur_frm.cscript.refresh = function(doc, cdt, cdn) {
+ cur_frm.cscript.get_tips(doc, cdt, cdn);
+}
\ No newline at end of file
diff --git a/tools/doctype/business_letter_type/business_letter_type.txt b/tools/doctype/business_letter_type/business_letter_type.txt
new file mode 100644
index 0000000..38a11b8
--- /dev/null
+++ b/tools/doctype/business_letter_type/business_letter_type.txt
@@ -0,0 +1 @@
+[{'section_style': 'Simple', 'is_transaction_doc': None, 'creation': '2010-04-20 11:03:59', 'search_fields': None, 'module': 'Tools', 'doctype': 'DocType', 'change_log': None, 'print_outline': '', 'owner': 'harshada@webnotestech.com', 'in_dialog': None, 'in_create': None, 'read_only': None, 'allow_email': None, 'dt_template': None, 'hide_heading': None, 'issingle': None, 'allow_rename': None, 'smallicon': None, 'allow_attach': None, 'show_in_menu': None, 'max_attachments': None, 'version': 3, 'menu_index': None, 'docstatus': 0, 'allow_copy': None, 'istable': None, 'description': None, 'parent': None, 'server_code': None, 'allow_trash': None, 'allow_print': None, 'autoname': 'field:letter_type', 'client_script_core': None, 'client_string': None, 'use_template': None, 'modified_by': 'ashwini@webnotestech.com', 'document_type': 'Master', 'name': 'Business Letter Type', 'idx': None, 'hide_toolbar': None, 'colour': 'White:FFF', 'client_script': None, 'modified': '2010-09-20 14:06:57', 'server_code_error': ' ', 'name_case': '', 'parenttype': None, 'read_only_onload': None, 'server_code_core': None, 'server_code_compiled': None, 'parent_node': None, 'parentfield': None}, {'cancel': None, 'amend': None, 'execute': None, 'modified_by': 'ashwini@webnotestech.com', 'name': 'PERM00839', 'parent': 'Business Letter Type', 'read': 1, 'create': 1, 'creation': '2010-04-20 11:03:59', 'modified': '2010-09-20 09:03:40', 'submit': None, 'doctype': 'DocPerm', 'write': 1, 'idx': 1, 'parenttype': 'DocType', 'role': 'System Manager', 'owner': 'harshada@webnotestech.com', 'docstatus': 0, 'permlevel': 0, 'match': None, 'parentfield': 'permissions'}, {'cancel': None, 'amend': None, 'execute': None, 'modified_by': 'ashwini@webnotestech.com', 'name': 'PERM00842', 'parent': 'Business Letter Type', 'read': 1, 'create': None, 'creation': '2010-04-20 11:06:28', 'modified': '2010-09-20 09:03:40', 'submit': None, 'doctype': 'DocPerm', 'write': None, 'idx': 2, 'parenttype': 'DocType', 'role': 'All', 'owner': 'harshada@webnotestech.com', 'docstatus': 0, 'permlevel': 0, 'match': None, 'parentfield': 'permissions'}, {'no_copy': None, 'oldfieldtype': 'Data', 'creation': '2010-04-20 11:03:59', 'doctype': 'DocField', 'oldfieldname': 'letter_type', 'owner': 'harshada@webnotestech.com', 'reqd': 1, 'in_filter': None, 'print_hide': None, 'modified_by': 'ashwini@webnotestech.com', 'label': 'Letter Type', 'width': None, 'trigger': None, 'depends_on': None, 'docstatus': 0, 'hidden': None, 'permlevel': 0, 'description': None, 'parent': 'Business Letter Type', 'search_index': None, 'allow_on_submit': None, 'icon': None, 'name': 'FL04791', 'idx': 1, 'default': None, 'colour': None, 'modified': '2010-09-20 09:03:40', 'parenttype': 'DocType', 'fieldname': 'letter_type', 'fieldtype': 'Data', 'options': None, 'report_hide': None, 'parentfield': 'fields'}]
\ No newline at end of file
diff --git a/tools/doctype/contact/__init__.py b/tools/doctype/contact/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tools/doctype/contact/__init__.py
diff --git a/tools/doctype/contact/contact.js b/tools/doctype/contact/contact.js
new file mode 100644
index 0000000..bca1615
--- /dev/null
+++ b/tools/doctype/contact/contact.js
@@ -0,0 +1,54 @@
+//--------- ONLOAD -------------
+cur_frm.cscript.onload = function(doc, cdt, cdn) {
+ if(doc.customer) cur_frm.add_fetch('customer', 'customer_name', 'customer_name');
+ if(doc.supplier) cur_frm.add_fetch('supplier', 'supplier_name', 'supplier_name');
+}
+/*
+//---------- on refresh ----------------------
+cur_frm.cscript.refresh = function(doc,cdt,cdn){
+
+}
+
+
+//------------- Trigger on customer ---------------------
+cur_frm.cscript.is_customer = function(doc,cdt,cdn){
+ if(!doc.is_customer){
+ doc.customer = doc.customer_name = doc.customer_address = doc.customer_group = '';
+ refresh_many(['customer','customer_name','customer_address','customer_group']);
+ }
+}
+
+//------------- Trigger on supplier -----------------------
+cur_frm.cscript.is_supplier = function(doc,cdt,cdn){
+ if(!doc.is_supplier){
+ doc.supplier = doc.supplier_name = doc.supplier_address = doc.supplier_type = '';
+ refresh_many(['supplier','supplier_address','supplier_name','supplier_type']);
+ }
+}
+
+//--------------- Trigger on sales partner ---------------------
+cur_frm.cscript.is_sales_partner = function(doc,cdt,cdn){
+ if(!doc.is_sales_partner){
+ doc.sales_partner = doc.sales_partner_address = doc.partner_type = '';
+ refresh_many(['sales_partner','sales_partner_address','partner_type']);
+ }
+}
+
+//----------- Trigger on supplier name ------------------------
+cur_frm.cscript.supplier = function(doc,cdt,cdn){
+ arg = {'dt':'Supplier','dn':doc.supplier,'nm':'supplier_name','fld':'supplier_address','type':'supplier_type'};
+ get_server_fields('get_address',docstring(arg),'',doc,cdt,cdn,1);
+}
+
+//------------ Trigger on customer name ------------------------
+cur_frm.cscript.customer = function(doc,cdt,cdn){
+ arg = {'dt':'Customer','dn':doc.customer,'nm':'customer_name','fld':'customer_address','type':'customer_group'};
+ get_server_fields('get_address',docstring(arg),'',doc,cdt,cdn,1);
+}
+
+//------------ Trigger on sales partner ------------------------
+cur_frm.cscript.sales_partner = function(doc,cdt,cdn){
+ arg = {'dt':'Sales Partner','dn':doc.sales_partner,'nm':'partner_name','fld':'sales_partner_address','type':'partner_type'};
+ get_server_fields('get_address',docstring(arg),'',doc,cdt,cdn,1);
+}
+*/
diff --git a/tools/doctype/contact/contact.py b/tools/doctype/contact/contact.py
new file mode 100644
index 0000000..7498619
--- /dev/null
+++ b/tools/doctype/contact/contact.py
@@ -0,0 +1,43 @@
+# Please edit this list and import only required elements
+import webnotes
+
+from webnotes.model.doc import Document
+from webnotes import session, form, msgprint, errprint
+
+sql = webnotes.conn.sql
+
+# -----------------------------------------------------------------------------------------
+
+class DocType:
+ def __init__(self, doc, doclist=[]):
+ self.doc = doc
+ self.doclist = doclist
+
+ def autoname(self):
+ if self.doc.customer:
+ self.doc.name = self.doc.first_name + (self.doc.last_name and ' ' + self.doc.last_name or '') + '-' + self.doc.customer
+ elif self.doc.supplier:
+ self.doc.name = self.doc.first_name + (self.doc.last_name and ' ' + self.doc.last_name or '') + '-' + self.doc.supplier
+ elif self.doc.sales_partner:
+ self.doc.name = self.doc.first_name + (self.doc.last_name and ' ' + self.doc.last_name or '') + '-' + self.doc.sales_partner
+
+ # filter out bad characters in name
+ self.doc.name = self.doc.name.replace('&','and').replace('.','').replace("'",'').replace('"','').replace(',','')
+
+#----------------------
+# Call to Validate
+#----------------------
+ def validate(self):
+ self.validate_primary_contact()
+
+#----------------------
+# Validate that there can only be one primary contact for particular customer, supplier
+#----------------------
+ def validate_primary_contact(self):
+ if self.doc.is_primary_contact == 1:
+ if self.doc.customer:
+ sql("update tabContact set is_primary_contact=0 where customer = '%s'" % (self.doc.customer))
+ elif self.doc.supplier:
+ sql("update tabContact set is_primary_contact=0 where supplier = '%s'" % (self.doc.supplier))
+ elif self.doc.sales_partner:
+ sql("update tabContact set is_primary_contact=0 where sales_partner = '%s'" % (self.doc.sales_partner))
diff --git a/tools/doctype/contact/contact.txt b/tools/doctype/contact/contact.txt
new file mode 100644
index 0000000..81a97a3
--- /dev/null
+++ b/tools/doctype/contact/contact.txt
@@ -0,0 +1,786 @@
+[
+ {
+ '_last_update': '1306748466',
+ '_user_tags': None,
+ 'allow_attach': None,
+ 'allow_copy': None,
+ 'allow_email': None,
+ 'allow_print': None,
+ 'allow_rename': None,
+ 'allow_trash': 1,
+ 'autoname': None,
+ 'change_log': None,
+ 'client_script': None,
+ 'client_script_core': None,
+ 'client_string': None,
+ 'colour': 'White:FFF',
+ 'creation': '2010-08-08 17:08:55',
+ 'description': None,
+ 'docstatus': 0,
+ 'doctype': 'DocType',
+ 'document_type': 'Master',
+ 'dt_template': None,
+ 'hide_heading': None,
+ 'hide_toolbar': None,
+ 'idx': None,
+ 'in_create': 0,
+ 'in_dialog': 1,
+ 'is_transaction_doc': None,
+ 'issingle': None,
+ 'istable': None,
+ 'max_attachments': None,
+ 'menu_index': None,
+ 'modified': '2011-05-30 16:34:29',
+ 'modified_by': 'Administrator',
+ 'module': 'Tools',
+ 'name': 'Contact',
+ 'name_case': None,
+ 'owner': 'Administrator',
+ 'parent': None,
+ 'parent_node': None,
+ 'parentfield': None,
+ 'parenttype': None,
+ 'print_outline': None,
+ 'read_only': None,
+ 'read_only_onload': None,
+ 'search_fields': None,
+ 'section_style': 'Simple',
+ 'server_code': None,
+ 'server_code_compiled': None,
+ 'server_code_core': None,
+ 'server_code_error': ' ',
+ 'show_in_menu': 0,
+ 'smallicon': None,
+ 'subject': '%(first_name)s %(last_name)s - Email: %(email_id)s | Contact: %(phone)s | Mobile: %(mobile_no)s',
+ 'tag_fields': None,
+ 'use_template': None,
+ 'version': 245
+ },
+ {
+ 'amend': None,
+ 'cancel': None,
+ 'create': None,
+ 'creation': '2010-10-27 14:40:07',
+ 'docstatus': 0,
+ 'doctype': 'DocPerm',
+ 'execute': None,
+ 'idx': 1,
+ 'match': None,
+ 'modified': '2011-05-30 16:34:29',
+ 'modified_by': 'Administrator',
+ 'name': 'PERM00721',
+ 'owner': 'Administrator',
+ 'parent': 'Contact',
+ 'parentfield': 'permissions',
+ 'parenttype': 'DocType',
+ 'permlevel': 0,
+ 'read': 1,
+ 'role': 'Sales User',
+ 'submit': None,
+ 'write': None
+ },
+ {
+ 'amend': None,
+ 'cancel': None,
+ 'create': None,
+ 'creation': '2010-10-27 14:40:07',
+ 'docstatus': 0,
+ 'doctype': 'DocPerm',
+ 'execute': None,
+ 'idx': 2,
+ 'match': None,
+ 'modified': '2011-05-30 16:34:29',
+ 'modified_by': 'Administrator',
+ 'name': 'PERM00722',
+ 'owner': 'Administrator',
+ 'parent': 'Contact',
+ 'parentfield': 'permissions',
+ 'parenttype': 'DocType',
+ 'permlevel': 0,
+ 'read': 1,
+ 'role': 'Purchase User',
+ 'submit': None,
+ 'write': None
+ },
+ {
+ 'amend': 0,
+ 'cancel': 1,
+ 'create': 1,
+ 'creation': '2010-08-08 17:08:55',
+ 'docstatus': 0,
+ 'doctype': 'DocPerm',
+ 'execute': None,
+ 'idx': 3,
+ 'match': None,
+ 'modified': '2011-05-30 16:34:29',
+ 'modified_by': 'Administrator',
+ 'name': 'PERM00125',
+ 'owner': 'Administrator',
+ 'parent': 'Contact',
+ 'parentfield': 'permissions',
+ 'parenttype': 'DocType',
+ 'permlevel': 0,
+ 'read': 1,
+ 'role': 'Sales Master Manager',
+ 'submit': 0,
+ 'write': 1
+ },
+ {
+ 'amend': None,
+ 'cancel': 1,
+ 'create': 1,
+ 'creation': '2010-08-08 17:08:55',
+ 'docstatus': 0,
+ 'doctype': 'DocPerm',
+ 'execute': None,
+ 'idx': 4,
+ 'match': None,
+ 'modified': '2011-05-30 16:34:29',
+ 'modified_by': 'Administrator',
+ 'name': 'PERM00128',
+ 'owner': 'Administrator',
+ 'parent': 'Contact',
+ 'parentfield': 'permissions',
+ 'parenttype': 'DocType',
+ 'permlevel': 0,
+ 'read': 1,
+ 'role': 'Purchase Master Manager',
+ 'submit': None,
+ 'write': 1
+ },
+ {
+ 'amend': None,
+ 'cancel': 1,
+ 'create': 1,
+ 'creation': '2010-08-08 17:08:55',
+ 'docstatus': 0,
+ 'doctype': 'DocPerm',
+ 'execute': None,
+ 'idx': 5,
+ 'match': None,
+ 'modified': '2011-05-30 16:34:29',
+ 'modified_by': 'Administrator',
+ 'name': 'PERM00129',
+ 'owner': 'Administrator',
+ 'parent': 'Contact',
+ 'parentfield': 'permissions',
+ 'parenttype': 'DocType',
+ 'permlevel': 0,
+ 'read': 1,
+ 'role': 'System Manager',
+ 'submit': None,
+ 'write': 1
+ },
+ {
+ 'allow_on_submit': None,
+ 'colour': 'White:FFF',
+ 'creation': '2011-05-27 18:28:50',
+ 'default': None,
+ 'depends_on': None,
+ 'description': None,
+ 'docstatus': 0,
+ 'doctype': 'DocField',
+ 'fieldname': None,
+ 'fieldtype': 'Section Break',
+ 'hidden': None,
+ 'icon': None,
+ 'idx': 1,
+ 'in_filter': None,
+ 'label': 'Contact Details',
+ 'modified': '2011-05-30 16:34:29',
+ 'modified_by': 'Administrator',
+ 'name': 'FL04808',
+ 'no_column': None,
+ 'no_copy': None,
+ 'oldfieldname': None,
+ 'oldfieldtype': 'Section Break',
+ 'options': None,
+ 'owner': 'ashwini@webnotestech.com',
+ 'parent': 'Contact',
+ 'parentfield': 'fields',
+ 'parenttype': 'DocType',
+ 'permlevel': 0,
+ 'print_hide': None,
+ 'report_hide': None,
+ 'reqd': None,
+ 'search_index': None,
+ 'trigger': None,
+ 'width': None
+ },
+ {
+ 'allow_on_submit': None,
+ 'colour': None,
+ 'creation': '2011-05-27 18:28:50',
+ 'default': None,
+ 'depends_on': None,
+ 'description': None,
+ 'docstatus': 0,
+ 'doctype': 'DocField',
+ 'fieldname': None,
+ 'fieldtype': 'Column Break',
+ 'hidden': None,
+ 'icon': None,
+ 'idx': 2,
+ 'in_filter': None,
+ 'label': None,
+ 'modified': '2011-05-30 16:34:29',
+ 'modified_by': 'Administrator',
+ 'name': 'FL04809',
+ 'no_column': None,
+ 'no_copy': None,
+ 'oldfieldname': None,
+ 'oldfieldtype': 'Column Break',
+ 'options': None,
+ 'owner': 'Administrator',
+ 'parent': 'Contact',
+ 'parentfield': 'fields',
+ 'parenttype': 'DocType',
+ 'permlevel': 0,
+ 'print_hide': None,
+ 'report_hide': None,
+ 'reqd': None,
+ 'search_index': None,
+ 'trigger': None,
+ 'width': '50%'
+ },
+ {
+ 'allow_on_submit': None,
+ 'colour': None,
+ 'creation': '2010-08-08 17:08:55',
+ 'default': None,
+ 'depends_on': None,
+ 'description': None,
+ 'docstatus': 0,
+ 'doctype': 'DocField',
+ 'fieldname': 'first_name',
+ 'fieldtype': 'Data',
+ 'hidden': None,
+ 'icon': None,
+ 'idx': 3,
+ 'in_filter': None,
+ 'label': 'First Name',
+ 'modified': '2011-05-30 16:34:29',
+ 'modified_by': 'Administrator',
+ 'name': 'FL00758',
+ 'no_column': None,
+ 'no_copy': None,
+ 'oldfieldname': 'first_name',
+ 'oldfieldtype': 'Data',
+ 'options': None,
+ 'owner': 'Administrator',
+ 'parent': 'Contact',
+ 'parentfield': 'fields',
+ 'parenttype': 'DocType',
+ 'permlevel': 0,
+ 'print_hide': None,
+ 'report_hide': None,
+ 'reqd': 1,
+ 'search_index': None,
+ 'trigger': None,
+ 'width': None
+ },
+ {
+ 'allow_on_submit': None,
+ 'colour': None,
+ 'creation': '2010-08-08 17:08:55',
+ 'default': None,
+ 'depends_on': None,
+ 'description': None,
+ 'docstatus': 0,
+ 'doctype': 'DocField',
+ 'fieldname': 'last_name',
+ 'fieldtype': 'Data',
+ 'hidden': None,
+ 'icon': None,
+ 'idx': 4,
+ 'in_filter': None,
+ 'label': 'Last Name',
+ 'modified': '2011-05-30 16:34:29',
+ 'modified_by': 'Administrator',
+ 'name': 'FL00759',
+ 'no_column': None,
+ 'no_copy': None,
+ 'oldfieldname': 'last_name',
+ 'oldfieldtype': 'Data',
+ 'options': None,
+ 'owner': 'Administrator',
+ 'parent': 'Contact',
+ 'parentfield': 'fields',
+ 'parenttype': 'DocType',
+ 'permlevel': 0,
+ 'print_hide': None,
+ 'report_hide': None,
+ 'reqd': None,
+ 'search_index': None,
+ 'trigger': None,
+ 'width': None
+ },
+ {
+ 'allow_on_submit': None,
+ 'colour': 'White:FFF',
+ 'creation': '2010-09-01 15:47:57',
+ 'default': None,
+ 'depends_on': 'eval:!doc.supplier && !doc.sales_partner',
+ 'description': None,
+ 'docstatus': 0,
+ 'doctype': 'DocField',
+ 'fieldname': 'customer',
+ 'fieldtype': 'Link',
+ 'hidden': None,
+ 'icon': None,
+ 'idx': 5,
+ 'in_filter': None,
+ 'label': 'Customer',
+ 'modified': '2011-05-30 16:34:29',
+ 'modified_by': 'Administrator',
+ 'name': 'FL03855',
+ 'no_column': None,
+ 'no_copy': None,
+ 'oldfieldname': 'customer',
+ 'oldfieldtype': 'Link',
+ 'options': 'Customer',
+ 'owner': 'harshada@webnotestech.com',
+ 'parent': 'Contact',
+ 'parentfield': 'fields',
+ 'parenttype': 'DocType',
+ 'permlevel': 0,
+ 'print_hide': 0,
+ 'report_hide': None,
+ 'reqd': None,
+ 'search_index': None,
+ 'trigger': 'Client',
+ 'width': None
+ },
+ {
+ 'allow_on_submit': None,
+ 'colour': 'White:FFF',
+ 'creation': '2011-05-17 14:03:55',
+ 'default': None,
+ 'depends_on': 'eval:!doc.supplier && !doc.sales_partner',
+ 'description': None,
+ 'docstatus': 0,
+ 'doctype': 'DocField',
+ 'fieldname': 'customer_name',
+ 'fieldtype': 'Data',
+ 'hidden': None,
+ 'icon': None,
+ 'idx': 6,
+ 'in_filter': None,
+ 'label': 'Customer Name',
+ 'modified': '2011-05-30 16:34:29',
+ 'modified_by': 'Administrator',
+ 'name': '000001020',
+ 'no_column': None,
+ 'no_copy': None,
+ 'oldfieldname': None,
+ 'oldfieldtype': None,
+ 'options': None,
+ 'owner': 'Administrator',
+ 'parent': 'Contact',
+ 'parentfield': 'fields',
+ 'parenttype': 'DocType',
+ 'permlevel': 1,
+ 'print_hide': None,
+ 'report_hide': None,
+ 'reqd': None,
+ 'search_index': None,
+ 'trigger': None,
+ 'width': None
+ },
+ {
+ 'allow_on_submit': None,
+ 'colour': 'White:FFF',
+ 'creation': '2011-04-25 18:42:39',
+ 'default': None,
+ 'depends_on': 'eval:!doc.customer && !doc.sales_partner',
+ 'description': None,
+ 'docstatus': 0,
+ 'doctype': 'DocField',
+ 'fieldname': 'supplier',
+ 'fieldtype': 'Link',
+ 'hidden': None,
+ 'icon': None,
+ 'idx': 7,
+ 'in_filter': None,
+ 'label': 'Supplier',
+ 'modified': '2011-05-30 16:34:29',
+ 'modified_by': 'Administrator',
+ 'name': '000000574',
+ 'no_column': None,
+ 'no_copy': None,
+ 'oldfieldname': None,
+ 'oldfieldtype': None,
+ 'options': 'Supplier',
+ 'owner': 'Administrator',
+ 'parent': 'Contact',
+ 'parentfield': 'fields',
+ 'parenttype': 'DocType',
+ 'permlevel': 0,
+ 'print_hide': None,
+ 'report_hide': None,
+ 'reqd': None,
+ 'search_index': None,
+ 'trigger': 'Client',
+ 'width': None
+ },
+ {
+ 'allow_on_submit': 0,
+ 'colour': 'White:FFF',
+ 'creation': '2011-05-17 14:03:55',
+ 'default': None,
+ 'depends_on': 'eval:!doc.customer && !doc.sales_partner',
+ 'description': None,
+ 'docstatus': 0,
+ 'doctype': 'DocField',
+ 'fieldname': 'supplier_name',
+ 'fieldtype': 'Data',
+ 'hidden': None,
+ 'icon': None,
+ 'idx': 8,
+ 'in_filter': None,
+ 'label': 'Supplier Name',
+ 'modified': '2011-05-30 16:34:29',
+ 'modified_by': 'Administrator',
+ 'name': '000001021',
+ 'no_column': None,
+ 'no_copy': None,
+ 'oldfieldname': None,
+ 'oldfieldtype': None,
+ 'options': None,
+ 'owner': 'Administrator',
+ 'parent': 'Contact',
+ 'parentfield': 'fields',
+ 'parenttype': 'DocType',
+ 'permlevel': 1,
+ 'print_hide': None,
+ 'report_hide': None,
+ 'reqd': None,
+ 'search_index': None,
+ 'trigger': None,
+ 'width': None
+ },
+ {
+ 'allow_on_submit': None,
+ 'colour': 'White:FFF',
+ 'creation': '2011-05-17 14:43:27',
+ 'default': None,
+ 'depends_on': 'eval:!doc.customer && !doc.supplier',
+ 'description': None,
+ 'docstatus': 0,
+ 'doctype': 'DocField',
+ 'fieldname': 'sales_partner',
+ 'fieldtype': 'Link',
+ 'hidden': None,
+ 'icon': None,
+ 'idx': 9,
+ 'in_filter': None,
+ 'label': 'Sales Partner',
+ 'modified': '2011-05-30 16:34:29',
+ 'modified_by': 'Administrator',
+ 'name': '000001030',
+ 'no_column': None,
+ 'no_copy': None,
+ 'oldfieldname': None,
+ 'oldfieldtype': None,
+ 'options': 'Sales Partner',
+ 'owner': 'Administrator',
+ 'parent': 'Contact',
+ 'parentfield': 'fields',
+ 'parenttype': 'DocType',
+ 'permlevel': 0,
+ 'print_hide': None,
+ 'report_hide': None,
+ 'reqd': None,
+ 'search_index': None,
+ 'trigger': None,
+ 'width': None
+ },
+ {
+ 'allow_on_submit': None,
+ 'colour': 'White:FFF',
+ 'creation': '2010-08-08 17:08:56',
+ 'default': '0',
+ 'depends_on': None,
+ 'description': None,
+ 'docstatus': 0,
+ 'doctype': 'DocField',
+ 'fieldname': 'is_primary_contact',
+ 'fieldtype': 'Check',
+ 'hidden': None,
+ 'icon': None,
+ 'idx': 10,
+ 'in_filter': None,
+ 'label': 'Is Primary Contact',
+ 'modified': '2011-05-30 16:34:29',
+ 'modified_by': 'Administrator',
+ 'name': 'FL00776',
+ 'no_column': None,
+ 'no_copy': None,
+ 'oldfieldname': 'is_primary_contact',
+ 'oldfieldtype': 'Select',
+ 'options': None,
+ 'owner': 'Administrator',
+ 'parent': 'Contact',
+ 'parentfield': 'fields',
+ 'parenttype': 'DocType',
+ 'permlevel': 0,
+ 'print_hide': None,
+ 'report_hide': None,
+ 'reqd': None,
+ 'search_index': None,
+ 'trigger': None,
+ 'width': None
+ },
+ {
+ 'allow_on_submit': None,
+ 'colour': None,
+ 'creation': '2011-05-27 18:28:50',
+ 'default': None,
+ 'depends_on': None,
+ 'description': None,
+ 'docstatus': 0,
+ 'doctype': 'DocField',
+ 'fieldname': None,
+ 'fieldtype': 'Column Break',
+ 'hidden': None,
+ 'icon': None,
+ 'idx': 11,
+ 'in_filter': None,
+ 'label': None,
+ 'modified': '2011-05-30 16:34:29',
+ 'modified_by': 'Administrator',
+ 'name': 'FL04810',
+ 'no_column': None,
+ 'no_copy': None,
+ 'oldfieldname': None,
+ 'oldfieldtype': 'Column Break',
+ 'options': None,
+ 'owner': 'ashwini@webnotestech.com',
+ 'parent': 'Contact',
+ 'parentfield': 'fields',
+ 'parenttype': 'DocType',
+ 'permlevel': 0,
+ 'print_hide': None,
+ 'report_hide': None,
+ 'reqd': None,
+ 'search_index': None,
+ 'trigger': None,
+ 'width': '50%'
+ },
+ {
+ 'allow_on_submit': None,
+ 'colour': None,
+ 'creation': '2010-08-08 17:08:56',
+ 'default': None,
+ 'depends_on': None,
+ 'description': None,
+ 'docstatus': 0,
+ 'doctype': 'DocField',
+ 'fieldname': 'email_id',
+ 'fieldtype': 'Data',
+ 'hidden': None,
+ 'icon': None,
+ 'idx': 12,
+ 'in_filter': None,
+ 'label': 'Email Id',
+ 'modified': '2011-05-30 16:34:29',
+ 'modified_by': 'Administrator',
+ 'name': 'FL00779',
+ 'no_column': None,
+ 'no_copy': None,
+ 'oldfieldname': 'email_id',
+ 'oldfieldtype': 'Data',
+ 'options': None,
+ 'owner': 'Administrator',
+ 'parent': 'Contact',
+ 'parentfield': 'fields',
+ 'parenttype': 'DocType',
+ 'permlevel': 0,
+ 'print_hide': None,
+ 'report_hide': None,
+ 'reqd': 1,
+ 'search_index': None,
+ 'trigger': None,
+ 'width': None
+ },
+ {
+ 'allow_on_submit': None,
+ 'colour': None,
+ 'creation': '2010-08-08 17:08:56',
+ 'default': None,
+ 'depends_on': None,
+ 'description': None,
+ 'docstatus': 0,
+ 'doctype': 'DocField',
+ 'fieldname': 'phone',
+ 'fieldtype': 'Data',
+ 'hidden': None,
+ 'icon': None,
+ 'idx': 13,
+ 'in_filter': None,
+ 'label': 'Phone',
+ 'modified': '2011-05-30 16:34:29',
+ 'modified_by': 'Administrator',
+ 'name': 'FL00778',
+ 'no_column': None,
+ 'no_copy': None,
+ 'oldfieldname': 'contact_no',
+ 'oldfieldtype': 'Data',
+ 'options': None,
+ 'owner': 'Administrator',
+ 'parent': 'Contact',
+ 'parentfield': 'fields',
+ 'parenttype': 'DocType',
+ 'permlevel': 0,
+ 'print_hide': None,
+ 'report_hide': None,
+ 'reqd': 1,
+ 'search_index': None,
+ 'trigger': None,
+ 'width': None
+ },
+ {
+ 'allow_on_submit': None,
+ 'colour': None,
+ 'creation': '2010-08-08 17:08:56',
+ 'default': None,
+ 'depends_on': None,
+ 'description': None,
+ 'docstatus': 0,
+ 'doctype': 'DocField',
+ 'fieldname': 'mobile_no',
+ 'fieldtype': 'Data',
+ 'hidden': None,
+ 'icon': None,
+ 'idx': 14,
+ 'in_filter': None,
+ 'label': 'Mobile No',
+ 'modified': '2011-05-30 16:34:30',
+ 'modified_by': 'Administrator',
+ 'name': 'FL00780',
+ 'no_column': None,
+ 'no_copy': None,
+ 'oldfieldname': 'mobile_no',
+ 'oldfieldtype': 'Data',
+ 'options': None,
+ 'owner': 'Administrator',
+ 'parent': 'Contact',
+ 'parentfield': 'fields',
+ 'parenttype': 'DocType',
+ 'permlevel': 0,
+ 'print_hide': None,
+ 'report_hide': None,
+ 'reqd': None,
+ 'search_index': None,
+ 'trigger': None,
+ 'width': None
+ },
+ {
+ 'allow_on_submit': None,
+ 'colour': 'White:FFF',
+ 'creation': '2011-04-26 12:04:54',
+ 'default': None,
+ 'depends_on': None,
+ 'description': 'Enter department to which this Contact belongs',
+ 'docstatus': 0,
+ 'doctype': 'DocField',
+ 'fieldname': 'department',
+ 'fieldtype': 'Data',
+ 'hidden': None,
+ 'icon': None,
+ 'idx': 15,
+ 'in_filter': None,
+ 'label': 'Department',
+ 'modified': '2011-05-30 16:34:30',
+ 'modified_by': 'Administrator',
+ 'name': '000000575',
+ 'no_column': None,
+ 'no_copy': None,
+ 'oldfieldname': None,
+ 'oldfieldtype': None,
+ 'options': 'Suggest',
+ 'owner': 'Administrator',
+ 'parent': 'Contact',
+ 'parentfield': 'fields',
+ 'parenttype': 'DocType',
+ 'permlevel': 0,
+ 'print_hide': None,
+ 'report_hide': None,
+ 'reqd': None,
+ 'search_index': None,
+ 'trigger': None,
+ 'width': None
+ },
+ {
+ 'allow_on_submit': None,
+ 'colour': 'White:FFF',
+ 'creation': '2011-04-26 12:04:54',
+ 'default': None,
+ 'depends_on': None,
+ 'description': 'Enter designation of this Contact',
+ 'docstatus': 0,
+ 'doctype': 'DocField',
+ 'fieldname': 'designation',
+ 'fieldtype': 'Data',
+ 'hidden': None,
+ 'icon': None,
+ 'idx': 16,
+ 'in_filter': None,
+ 'label': 'Designation',
+ 'modified': '2011-05-30 16:34:30',
+ 'modified_by': 'Administrator',
+ 'name': '000000576',
+ 'no_column': None,
+ 'no_copy': None,
+ 'oldfieldname': None,
+ 'oldfieldtype': None,
+ 'options': 'Suggest',
+ 'owner': 'Administrator',
+ 'parent': 'Contact',
+ 'parentfield': 'fields',
+ 'parenttype': 'DocType',
+ 'permlevel': 0,
+ 'print_hide': None,
+ 'report_hide': None,
+ 'reqd': None,
+ 'search_index': None,
+ 'trigger': None,
+ 'width': None
+ },
+ {
+ 'allow_on_submit': None,
+ 'colour': None,
+ 'creation': '2010-08-08 17:08:55',
+ 'default': None,
+ 'depends_on': None,
+ 'description': None,
+ 'docstatus': 0,
+ 'doctype': 'DocField',
+ 'fieldname': 'trash_reason',
+ 'fieldtype': 'Small Text',
+ 'hidden': None,
+ 'icon': None,
+ 'idx': 17,
+ 'in_filter': None,
+ 'label': 'Trash Reason',
+ 'modified': '2011-05-30 16:34:30',
+ 'modified_by': 'Administrator',
+ 'name': 'FL00755',
+ 'no_column': None,
+ 'no_copy': None,
+ 'oldfieldname': 'trash_reason',
+ 'oldfieldtype': 'Small Text',
+ 'options': None,
+ 'owner': 'Administrator',
+ 'parent': 'Contact',
+ 'parentfield': 'fields',
+ 'parenttype': 'DocType',
+ 'permlevel': 1,
+ 'print_hide': None,
+ 'report_hide': None,
+ 'reqd': None,
+ 'search_index': None,
+ 'trigger': None,
+ 'width': None
+ }
+]
\ No newline at end of file
diff --git a/tools/doctype/contact_detail/__init__.py b/tools/doctype/contact_detail/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tools/doctype/contact_detail/__init__.py
diff --git a/tools/doctype/contact_detail/contact_detail.txt b/tools/doctype/contact_detail/contact_detail.txt
new file mode 100644
index 0000000..6f58968
--- /dev/null
+++ b/tools/doctype/contact_detail/contact_detail.txt
@@ -0,0 +1 @@
+[{'section_style': 'Tray', 'is_transaction_doc': None, 'creation': '2009-03-30 18:16:41', 'search_fields': None, 'module': 'Tools', 'doctype': 'DocType', 'change_log': None, 'print_outline': '', 'owner': 'Administrator', 'in_dialog': None, 'in_create': None, 'read_only': None, 'allow_email': None, 'dt_template': None, 'hide_heading': None, 'issingle': None, 'allow_rename': None, 'smallicon': '', 'allow_attach': None, 'show_in_menu': 0, 'max_attachments': None, 'version': 5, 'menu_index': None, 'docstatus': 0, 'allow_copy': None, 'istable': 1, 'description': None, 'parent': None, 'server_code': None, 'allow_trash': None, 'allow_print': None, 'autoname': 'CD/.#####', 'client_script_core': None, 'client_string': None, 'use_template': None, 'modified_by': 'Administrator', 'document_type': None, 'name': 'Contact Detail', 'idx': None, 'hide_toolbar': None, 'colour': 'White:FFF', 'client_script': None, 'modified': '2010-09-20 14:06:57', 'server_code_error': None, 'name_case': '', 'parenttype': None, 'read_only_onload': None, 'server_code_core': None, 'server_code_compiled': None, 'parent_node': None, 'parentfield': None}, {'no_copy': None, 'oldfieldtype': 'Data', 'creation': '2009-03-30 18:16:41', 'doctype': 'DocField', 'oldfieldname': 'contact_person', 'owner': 'Administrator', 'reqd': 1, 'in_filter': None, 'print_hide': None, 'modified_by': 'Administrator', 'label': 'Contact Person', 'width': None, 'trigger': None, 'depends_on': None, 'docstatus': 0, 'hidden': None, 'permlevel': 0, 'description': None, 'parent': 'Contact Detail', 'search_index': None, 'allow_on_submit': None, 'icon': None, 'name': 'FL01574', 'idx': 1, 'default': None, 'colour': None, 'modified': '2009-07-20 19:14:16', 'parenttype': 'DocType', 'fieldname': 'contact_person', 'fieldtype': 'Data', 'options': None, 'report_hide': None, 'parentfield': 'fields'}, {'no_copy': None, 'oldfieldtype': 'Data', 'creation': '2009-03-30 18:16:41', 'doctype': 'DocField', 'oldfieldname': 'contact_no', 'owner': 'Administrator', 'reqd': 1, 'in_filter': None, 'print_hide': None, 'modified_by': 'Administrator', 'label': 'Contact No', 'width': None, 'trigger': None, 'depends_on': None, 'docstatus': 0, 'hidden': None, 'permlevel': 0, 'description': None, 'parent': 'Contact Detail', 'search_index': None, 'allow_on_submit': None, 'icon': None, 'name': 'FL01575', 'idx': 2, 'default': None, 'colour': None, 'modified': '2009-07-20 19:14:16', 'parenttype': 'DocType', 'fieldname': 'contact_no', 'fieldtype': 'Data', 'options': None, 'report_hide': None, 'parentfield': 'fields'}, {'no_copy': None, 'oldfieldtype': 'Data', 'creation': '2009-03-30 18:16:41', 'doctype': 'DocField', 'oldfieldname': 'department', 'owner': 'Administrator', 'reqd': None, 'in_filter': None, 'print_hide': None, 'modified_by': 'Administrator', 'label': 'Department', 'width': None, 'trigger': None, 'depends_on': None, 'docstatus': 0, 'hidden': None, 'permlevel': 0, 'description': None, 'parent': 'Contact Detail', 'search_index': None, 'allow_on_submit': None, 'icon': None, 'name': 'FL01576', 'idx': 3, 'default': None, 'colour': None, 'modified': '2009-07-20 19:14:16', 'parenttype': 'DocType', 'fieldname': 'department', 'fieldtype': 'Data', 'options': None, 'report_hide': None, 'parentfield': 'fields'}, {'no_copy': None, 'oldfieldtype': 'Data', 'creation': '2009-05-06 17:14:06', 'doctype': 'DocField', 'oldfieldname': 'designation', 'owner': 'Administrator', 'reqd': None, 'in_filter': None, 'print_hide': None, 'modified_by': 'Administrator', 'label': 'Designation', 'width': None, 'trigger': None, 'depends_on': None, 'docstatus': 0, 'hidden': None, 'permlevel': 0, 'description': None, 'parent': 'Contact Detail', 'search_index': None, 'allow_on_submit': None, 'icon': None, 'name': 'FL02006', 'idx': 4, 'default': None, 'colour': None, 'modified': '2009-07-20 19:14:16', 'parenttype': 'DocType', 'fieldname': 'designation', 'fieldtype': 'Data', 'options': None, 'report_hide': None, 'parentfield': 'fields'}, {'no_copy': None, 'oldfieldtype': 'Small Text', 'creation': '2009-05-19 10:57:20', 'doctype': 'DocField', 'oldfieldname': 'email_id', 'owner': 'Administrator', 'reqd': None, 'in_filter': None, 'print_hide': None, 'modified_by': 'Administrator', 'label': 'Email Id', 'width': None, 'trigger': None, 'depends_on': None, 'docstatus': 0, 'hidden': None, 'permlevel': 0, 'description': None, 'parent': 'Contact Detail', 'search_index': None, 'allow_on_submit': None, 'icon': None, 'name': 'FL02092', 'idx': 5, 'default': None, 'colour': None, 'modified': '2009-07-20 19:14:16', 'parenttype': 'DocType', 'fieldname': 'email_id', 'fieldtype': 'Small Text', 'options': None, 'report_hide': None, 'parentfield': 'fields'}]
\ No newline at end of file
diff --git a/tools/doctype/file_browser_control/__init__.py b/tools/doctype/file_browser_control/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tools/doctype/file_browser_control/__init__.py
diff --git a/tools/doctype/file_browser_control/file_browser_control.py b/tools/doctype/file_browser_control/file_browser_control.py
new file mode 100644
index 0000000..8008ae9
--- /dev/null
+++ b/tools/doctype/file_browser_control/file_browser_control.py
@@ -0,0 +1,198 @@
+# Please edit this list and import only required elements
+import webnotes
+
+from webnotes.utils import add_days, add_months, add_years, cint, cstr, date_diff, default_fields, flt, fmt_money, formatdate, generate_hash, getTraceback, get_defaults, get_first_day, get_last_day, getdate, has_common, month_name, now, nowdate, replace_newlines, sendmail, set_default, str_esc_quote, user_format, validate_email_add
+from webnotes.model import db_exists
+from webnotes.model.doc import Document, addchild, removechild, getchildren, make_autoname, SuperDocType
+from webnotes.model.doclist import getlist, copy_doclist
+from webnotes.model.code import get_obj, get_server_obj, run_server_obj, updatedb, check_syntax
+from webnotes import session, form, is_testing, msgprint, errprint
+
+set = webnotes.conn.set
+sql = webnotes.conn.sql
+get_value = webnotes.conn.get_value
+in_transaction = webnotes.conn.in_transaction
+convert_to_lists = webnotes.conn.convert_to_lists
+
+# -----------------------------------------------------------------------------------------
+
+
+class DocType:
+ def __init__(self,doc,doclist=[]):
+ self.doc = doc
+ self.doclist = doclist
+
+ # All root file groups(where parent_group is null).
+ def get_root_file_grps(self):
+ fl_grp = convert_to_lists(sql("select name,group_name,ifnull(can_edit,''),ifnull(can_view,''),owner from `tabFile Group` where (parent_group='' or parent_group is null)"))
+ return fl_grp
+
+ # Get children of selected file group.
+ def get_children(self,grp):
+ ret = {}
+ ret['parent_grp'] = grp
+
+ fl_grp = convert_to_lists(sql("select name,group_name,ifnull(can_edit,''),ifnull(can_view,''),owner from `tabFile Group` where parent_group=%s",grp))
+ ret['fl_grp'] = fl_grp or ''
+ fl = convert_to_lists(sql("select name,ifnull(file_name,''),ifnull(file_list,''),ifnull(can_edit,''),ifnull(can_view,''),owner from tabFile where file_group=%s and (file_name != '' and file_name is not null)",grp))
+ ret['fl'] = fl or ''
+
+ return ret
+
+ # Create a new file group.
+ def create_new_grp(self,arg):
+ arg = eval(arg)
+
+ grp = Document('File Group')
+ grp.group_name = arg['grp_nm']
+ grp.parent_group = arg['parent_grp']
+ grp.description = arg['desc']
+ grp.name = arg['grp_nm']
+ grp.save(1)
+ msgprint('Created a New Group')
+ return grp.name
+
+ # Create a new file.
+ def create_new_file(self,arg):
+ arg = eval(arg)
+
+ f = Document('File')
+ f.file_name = arg['file_name']
+ f.description = arg['desc']
+ f.type = arg['type']
+ f.file_group = arg['file_grp']
+ f_obj = get_obj(doc=f)
+ f_obj.validate()
+ f_obj.doc.save(1)
+ msgprint('Created a New File')
+ ret = {
+ 'name' : f_obj.doc.name,
+ 'label' : f_obj.doc.file_name
+ }
+ return cstr(ret)
+
+ # Update changes done to selected file group.
+ def update_grp(self,arg):
+ arg = eval(arg)
+ sql("update `tabFile Group` set group_name=%s, parent_group=%s, description=%s where name=%s",(arg['grp_nm'],arg['parent_grp'],arg['desc'],arg['name']))
+ msgprint("Changes are saved.")
+ return arg['name']
+
+ # Update changes done to selected file.
+ def update_file(self,arg):
+ arg = eval(arg)
+ sql("update `tabFile` set description=%s, file_group=%s where name=%s",(arg['desc'],arg['file_grp'],arg['name']))
+ msgprint("Changes are saved.")
+ return arg['name']
+
+ # Get details of selected file.
+ def get_file_details(self,file_id):
+ file_det = convert_to_lists(sql("select name,file_name, description, file_group, file_list from tabFile where name=%s",file_id))
+ file_det = {
+ 'name' : file_det[0][0] or '',
+ 'file_name' : file_det[0][1] or '',
+ 'description' : file_det[0][2] or '',
+ 'file_group' : file_det[0][3] or '',
+ 'file_list' : file_det[0][4] or ''
+ }
+ return file_det
+
+ # Delete File Data and File record.
+ def delete(self,arg):
+ arg = eval(arg)
+ if arg['dt'] == 'File Group':
+ sql("delete from `tabFile Group` where name= %s", arg['dn'])
+ elif arg['dt'] == 'File':
+ file_list = sql("select file_list from tabFile where name=%s", arg['dn'])[0][0] or ''
+ f_id = file_list.split(',')[-1]
+ if f_id:
+ sql("delete from `tabFile Data` where name=%s", f_id)
+ sql("delete from tabFile where name = %s", arg['dn'])
+ else:
+ pass
+
+ #Move to another group.
+ def move(self,arg):
+ msgprint('need to write code')
+
+ # Upload Image
+ def upload_many(self,form):
+ import os
+ # from file browser
+ if form.getvalue('form_name') == 'File Browser':
+ if form.getvalue('filedata'):
+ i = form['filedata']
+
+ #creat file data
+ fd = Document('File Data')
+ fd.blob_content = i.file.read()
+ fd.file_name = i.filename
+
+ file_det = form.getvalue('file_det').split('~~')
+
+ if(file_det[0] == 'NIL'):
+ file_desc = ''
+ else:
+ file_desc = file_det[0]
+
+ if(file_det[1] == 'NIL'):
+ file_grp = ''
+ return 'File Group is mandatory.'
+ raise Exception
+ else:
+ file_grp = file_det[1]
+
+ if "" in fd.file_name:
+ fd.file_name = fd.file_name.split("")[-1]
+ if '/' in fd.file_name:
+ fd.file_name = fd.file_name.split('/')[-1]
+ fd.save(1)
+
+ f = Document('File')
+ f.file_list = fd.file_name + ',' + fd.name
+ f.file_name = fd.file_name
+ f.description = file_desc
+ f.file_group = file_grp
+ f.save(1)
+
+ ret = {
+ 'name' : f.name,
+ 'file_name' : f.file_name
+ }
+
+ return cstr(ret)
+ else:
+ return 'No file found.'
+ else:
+ return 'No file found.'
+
+ # Get all system roles.
+ def get_all_roles(self):
+ roles = convert_to_lists(sql("select name from tabRole"))
+ return roles
+
+ # Get details for selected File Group.
+ def get_fg_details(self,grp):
+ grp_det = convert_to_lists(sql("select name,group_name, ifnull(parent_group,''), ifnull(description,''), ifnull(can_edit,''),ifnull(can_view,''),owner from `tabFile Group` where name=%s",grp))
+ grp_det = {
+ 'Name' : grp_det[0][0] or '',
+ 'Group Name' : grp_det[0][1] or '',
+ 'Parent Group' : grp_det[0][2] or '',
+ 'Description' : grp_det[0][3] or '',
+ 'Can Edit' : grp_det[0][4] or '',
+ 'Can View' : grp_det[0][5] or '',
+ 'Owner' : grp_det[0][6] or ''
+ }
+ return grp_det
+
+ # Update Edit/ View privileges to selected File/ File Group.
+ def update_privileges(self,arg):
+ arg = eval(arg)
+ sql("update `tab%s` set can_edit='%s', can_view='%s' where name='%s'" % (arg['type'],arg['edit_roles'], arg['view_roles'], arg['name']))
+ msgprint('Privileges updated.')
+
+ # Get Edit/ View privileges from selected File/ File Group.
+ def get_privileges(self,arg):
+ arg = eval(arg)
+ privilege = convert_to_lists(sql("select ifnull(can_edit,''), ifnull(can_view,''),owner from `tab%s` where name='%s'" % (arg['dt'],arg['dn'])))
+ return privilege
\ No newline at end of file
diff --git a/tools/doctype/file_browser_control/file_browser_control.txt b/tools/doctype/file_browser_control/file_browser_control.txt
new file mode 100644
index 0000000..08b7f59
--- /dev/null
+++ b/tools/doctype/file_browser_control/file_browser_control.txt
@@ -0,0 +1,55 @@
+[
+ {
+ 'allow_attach': None,
+ 'allow_copy': None,
+ 'allow_email': None,
+ 'allow_print': None,
+ 'allow_rename': None,
+ 'allow_trash': None,
+ 'autoname': None,
+ 'change_log': None,
+ 'client_script': None,
+ 'client_script_core': None,
+ 'client_string': None,
+ 'colour': 'White:FFF',
+ 'creation': '2009-10-28 10:25:03',
+ 'description': None,
+ 'docstatus': 0,
+ 'doctype': 'DocType',
+ 'document_type': None,
+ 'dt_template': None,
+ 'hide_heading': None,
+ 'hide_toolbar': None,
+ 'idx': None,
+ 'in_create': None,
+ 'in_dialog': None,
+ 'is_transaction_doc': None,
+ 'issingle': 1,
+ 'istable': None,
+ 'max_attachments': None,
+ 'menu_index': None,
+ 'modified': '2010-09-20 14:06:57',
+ 'modified_by': 'Administrator',
+ 'module': 'Tools',
+ 'name': 'File Browser Control',
+ 'name_case': None,
+ 'owner': 'Administrator',
+ 'parent': None,
+ 'parent_node': None,
+ 'parentfield': None,
+ 'parenttype': None,
+ 'print_outline': None,
+ 'read_only': None,
+ 'read_only_onload': None,
+ 'search_fields': None,
+ 'section_style': 'Simple',
+ 'server_code': None,
+ 'server_code_compiled': None,
+ 'server_code_core': None,
+ 'server_code_error': None,
+ 'show_in_menu': 0,
+ 'smallicon': None,
+ 'use_template': None,
+ 'version': 81
+ }
+]
\ No newline at end of file
diff --git a/tools/doctype/rating_template/__init__.py b/tools/doctype/rating_template/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tools/doctype/rating_template/__init__.py
diff --git a/tools/doctype/rating_template/rating_template.txt b/tools/doctype/rating_template/rating_template.txt
new file mode 100644
index 0000000..870e125
--- /dev/null
+++ b/tools/doctype/rating_template/rating_template.txt
@@ -0,0 +1 @@
+[{'section_style': 'Simple', 'is_transaction_doc': None, 'creation': '2009-11-12 18:12:18', 'search_fields': None, 'module': 'Tools', 'doctype': 'DocType', 'change_log': None, 'print_outline': '', 'owner': 'Administrator', 'in_dialog': None, 'in_create': None, 'read_only': None, 'allow_email': None, 'dt_template': None, 'hide_heading': None, 'issingle': None, 'allow_rename': None, 'smallicon': '', 'allow_attach': None, 'show_in_menu': 0, 'max_attachments': None, 'version': 4, 'menu_index': None, 'docstatus': 0, 'allow_copy': None, 'istable': None, 'description': None, 'parent': None, 'server_code': None, 'allow_trash': None, 'allow_print': None, 'autoname': 'field:template_name', 'client_script_core': None, 'client_string': None, 'use_template': None, 'modified_by': 'Administrator', 'document_type': None, 'name': 'Rating Template', 'idx': None, 'hide_toolbar': None, 'colour': 'White:FFF', 'client_script': None, 'modified': '2010-09-20 14:06:57', 'server_code_error': ' ', 'name_case': '', 'parenttype': None, 'read_only_onload': None, 'server_code_core': None, 'server_code_compiled': None, 'parent_node': None, 'parentfield': None}, {'cancel': None, 'amend': None, 'execute': None, 'modified_by': 'Administrator', 'name': 'PERM00516', 'parent': 'Rating Template', 'read': 1, 'create': 1, 'creation': '2009-11-12 18:12:18', 'modified': '2010-08-06 01:21:20', 'submit': None, 'doctype': 'DocPerm', 'write': 1, 'idx': 1, 'parenttype': 'DocType', 'role': 'Administrator', 'owner': 'Administrator', 'docstatus': 0, 'permlevel': 0, 'match': None, 'parentfield': 'permissions'}, {'no_copy': None, 'oldfieldtype': 'Data', 'creation': '2009-11-12 18:12:18', 'doctype': 'DocField', 'oldfieldname': 'template_name', 'owner': 'Administrator', 'reqd': None, 'in_filter': None, 'print_hide': None, 'modified_by': 'Administrator', 'label': 'Template Name', 'width': None, 'trigger': None, 'depends_on': None, 'docstatus': 0, 'hidden': None, 'permlevel': 0, 'description': None, 'parent': 'Rating Template', 'search_index': None, 'allow_on_submit': None, 'icon': None, 'name': 'FL03336', 'idx': 1, 'default': None, 'colour': None, 'modified': '2010-08-06 01:21:20', 'parenttype': 'DocType', 'fieldname': 'template_name', 'fieldtype': 'Data', 'options': None, 'report_hide': None, 'parentfield': 'fields'}, {'no_copy': None, 'oldfieldtype': 'Int', 'creation': '2009-11-12 18:12:18', 'doctype': 'DocField', 'oldfieldname': 'total_stars', 'owner': 'Administrator', 'reqd': None, 'in_filter': None, 'print_hide': None, 'modified_by': 'Administrator', 'label': 'Total Stars', 'width': None, 'trigger': None, 'depends_on': None, 'docstatus': 0, 'hidden': None, 'permlevel': 0, 'description': None, 'parent': 'Rating Template', 'search_index': None, 'allow_on_submit': None, 'icon': None, 'name': 'FL03337', 'idx': 2, 'default': None, 'colour': None, 'modified': '2010-08-06 01:21:20', 'parenttype': 'DocType', 'fieldname': 'total_stars', 'fieldtype': 'Int', 'options': None, 'report_hide': None, 'parentfield': 'fields'}, {'no_copy': None, 'oldfieldtype': 'Section Break', 'creation': '2009-11-12 18:12:18', 'doctype': 'DocField', 'oldfieldname': None, 'owner': 'Administrator', 'reqd': None, 'in_filter': None, 'print_hide': None, 'modified_by': 'Administrator', 'label': 'Rating Template Details', 'width': None, 'trigger': None, 'depends_on': None, 'docstatus': 0, 'hidden': None, 'permlevel': 0, 'description': None, 'parent': 'Rating Template', 'search_index': None, 'allow_on_submit': None, 'icon': None, 'name': 'FL03338', 'idx': 3, 'default': None, 'colour': None, 'modified': '2010-08-06 01:21:20', 'parenttype': 'DocType', 'fieldname': None, 'fieldtype': 'Section Break', 'options': None, 'report_hide': None, 'parentfield': 'fields'}, {'no_copy': None, 'oldfieldtype': 'Table', 'creation': '2009-11-12 18:12:18', 'doctype': 'DocField', 'oldfieldname': 'rating_template_details', 'owner': 'Administrator', 'reqd': None, 'in_filter': None, 'print_hide': None, 'modified_by': 'Administrator', 'label': 'Rating Template Details1', 'width': None, 'trigger': None, 'depends_on': None, 'docstatus': 0, 'hidden': None, 'permlevel': 0, 'description': None, 'parent': 'Rating Template', 'search_index': None, 'allow_on_submit': None, 'icon': None, 'name': 'FL03339', 'idx': 4, 'default': None, 'colour': None, 'modified': '2010-08-06 01:21:20', 'parenttype': 'DocType', 'fieldname': 'rating_template_details', 'fieldtype': 'Table', 'options': 'Rating Template Detail', 'report_hide': None, 'parentfield': 'fields'}]
\ No newline at end of file
diff --git a/tools/doctype/rating_template_detail/__init__.py b/tools/doctype/rating_template_detail/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tools/doctype/rating_template_detail/__init__.py
diff --git a/tools/doctype/rating_template_detail/rating_template_detail.txt b/tools/doctype/rating_template_detail/rating_template_detail.txt
new file mode 100644
index 0000000..31050a5
--- /dev/null
+++ b/tools/doctype/rating_template_detail/rating_template_detail.txt
@@ -0,0 +1 @@
+[{'section_style': 'Simple', 'is_transaction_doc': None, 'creation': '2009-11-12 18:13:41', 'search_fields': None, 'module': 'Tools', 'doctype': 'DocType', 'change_log': None, 'print_outline': '', 'owner': 'Administrator', 'in_dialog': None, 'in_create': None, 'read_only': None, 'allow_email': None, 'dt_template': None, 'hide_heading': None, 'issingle': None, 'allow_rename': None, 'smallicon': '', 'allow_attach': None, 'show_in_menu': 0, 'max_attachments': None, 'version': 3, 'menu_index': None, 'docstatus': 0, 'allow_copy': None, 'istable': 1, 'description': None, 'parent': None, 'server_code': None, 'allow_trash': None, 'allow_print': None, 'autoname': 'RTD/.#####', 'client_script_core': None, 'client_string': None, 'use_template': None, 'modified_by': 'Administrator', 'document_type': None, 'name': 'Rating Template Detail', 'idx': None, 'hide_toolbar': None, 'colour': 'White:FFF', 'client_script': None, 'modified': '2010-09-20 14:06:57', 'server_code_error': None, 'name_case': '', 'parenttype': None, 'read_only_onload': None, 'server_code_core': None, 'server_code_compiled': None, 'parent_node': None, 'parentfield': None}, {'no_copy': None, 'oldfieldtype': 'Int', 'creation': '2009-11-12 18:13:41', 'doctype': 'DocField', 'oldfieldname': 'rating', 'owner': 'Administrator', 'reqd': None, 'in_filter': None, 'print_hide': None, 'modified_by': 'Administrator', 'label': 'Rating', 'width': None, 'trigger': None, 'depends_on': None, 'docstatus': 0, 'hidden': None, 'permlevel': 0, 'description': None, 'parent': 'Rating Template Detail', 'search_index': None, 'allow_on_submit': None, 'icon': None, 'name': 'FL03340', 'idx': 1, 'default': None, 'colour': None, 'modified': '2010-08-06 01:21:10', 'parenttype': 'DocType', 'fieldname': 'rating', 'fieldtype': 'Int', 'options': None, 'report_hide': None, 'parentfield': 'fields'}, {'no_copy': None, 'oldfieldtype': 'Data', 'creation': '2009-11-12 18:13:41', 'doctype': 'DocField', 'oldfieldname': 'description', 'owner': 'Administrator', 'reqd': None, 'in_filter': None, 'print_hide': None, 'modified_by': 'Administrator', 'label': 'Description', 'width': None, 'trigger': None, 'depends_on': None, 'docstatus': 0, 'hidden': None, 'permlevel': 0, 'description': None, 'parent': 'Rating Template Detail', 'search_index': None, 'allow_on_submit': None, 'icon': None, 'name': 'FL03341', 'idx': 2, 'default': None, 'colour': None, 'modified': '2010-08-06 01:21:10', 'parenttype': 'DocType', 'fieldname': 'description', 'fieldtype': 'Data', 'options': None, 'report_hide': None, 'parentfield': 'fields'}]
\ No newline at end of file
diff --git a/tools/doctype/rating_widget_control/__init__.py b/tools/doctype/rating_widget_control/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tools/doctype/rating_widget_control/__init__.py
diff --git a/tools/doctype/rating_widget_control/rating_widget_control.py b/tools/doctype/rating_widget_control/rating_widget_control.py
new file mode 100644
index 0000000..d5c5bad
--- /dev/null
+++ b/tools/doctype/rating_widget_control/rating_widget_control.py
@@ -0,0 +1,51 @@
+# Please edit this list and import only required elements
+import webnotes
+
+from webnotes.utils import add_days, add_months, add_years, cint, cstr, date_diff, default_fields, flt, fmt_money, formatdate, generate_hash, getTraceback, get_defaults, get_first_day, get_last_day, getdate, has_common, month_name, now, nowdate, replace_newlines, sendmail, set_default, str_esc_quote, user_format, validate_email_add
+from webnotes.model import db_exists
+from webnotes.model.doc import Document, addchild, removechild, getchildren, make_autoname, SuperDocType
+from webnotes.model.doclist import getlist, copy_doclist
+from webnotes.model.code import get_obj, get_server_obj, run_server_obj, updatedb, check_syntax
+from webnotes import session, form, is_testing, msgprint, errprint
+
+set = webnotes.conn.set
+sql = webnotes.conn.sql
+get_value = webnotes.conn.get_value
+in_transaction = webnotes.conn.in_transaction
+convert_to_lists = webnotes.conn.convert_to_lists
+
+# -----------------------------------------------------------------------------------------
+
+
+class DocType:
+ def __init__(self,d,dl):
+ self.doc, self.doclist = d, dl
+
+ def show_my_rating(self,arg):
+ arg = eval(arg)
+ ret = {}
+ ret['total_stars'] = convert_to_lists(sql("select total_stars from `tabRating Template` where name = %s", arg['template']))
+ ret['avg_rating'] = convert_to_lists(sql("select count(name),round(sum(rating_stars)/count(name)) from `tabRating Widget Record` where rating_doctype = %s and rating_docname = %s and rating_template = %s",(arg['dt'], arg['dn'], arg['template'])))
+ rating_details = convert_to_lists(sql("select name, rating_stars, rating_description, rating_template, rating_by, rating_to, rating_date, rating_time, rating_doctype, rating_docname from `tabRating Widget Record` where rating_by = %s and rating_doctype = %s and rating_docname = %s and rating_template = %s",(arg['by'], arg['dt'], arg['dn'], arg['template'])))
+ if rating_details:
+ ret['rating_details'] = rating_details or ''
+ ret['flag'] = 1
+ else:
+ ret['rating_desc'] = convert_to_lists(sql("select rating, description from `tabRating Template Detail` where parent = %s", arg['template']))
+ ret['flag'] = 0
+ return ret
+
+ def add_rating(self,arg):
+ import time
+ arg = eval(arg)
+ rw = Document('Rating Widget Record')
+ rw.rating_stars = arg['rating']
+ rw.rating_description = arg['desc']
+ rw.rating_template = arg['template']
+ rw.rating_by = arg['rating_by']
+ rw.rating_to = Document(arg['dt'],arg['dn']).owner
+ rw.rating_date = nowdate()
+ rw.rating_time = time.strftime('%H:%M')
+ rw.rating_doctype = arg['dt']
+ rw.rating_docname = arg['dn']
+ rw.save(1)
\ No newline at end of file
diff --git a/tools/doctype/rating_widget_control/rating_widget_control.txt b/tools/doctype/rating_widget_control/rating_widget_control.txt
new file mode 100644
index 0000000..34c6ccf
--- /dev/null
+++ b/tools/doctype/rating_widget_control/rating_widget_control.txt
@@ -0,0 +1 @@
+[{'section_style': 'Simple', 'is_transaction_doc': None, 'creation': '2009-11-12 18:26:54', 'search_fields': None, 'module': 'Tools', 'doctype': 'DocType', 'change_log': None, 'print_outline': '', 'owner': 'Administrator', 'in_dialog': None, 'in_create': None, 'read_only': None, 'allow_email': None, 'dt_template': None, 'hide_heading': None, 'issingle': 1, 'allow_rename': None, 'smallicon': None, 'allow_attach': None, 'show_in_menu': 0, 'max_attachments': None, 'version': 3, 'menu_index': None, 'docstatus': 0, 'allow_copy': None, 'istable': None, 'description': None, 'parent': None, 'server_code': None, 'allow_trash': None, 'allow_print': None, 'autoname': None, 'client_script_core': None, 'client_string': None, 'use_template': None, 'modified_by': 'Administrator', 'document_type': None, 'name': 'Rating Widget Control', 'idx': None, 'hide_toolbar': None, 'colour': 'White:FFF', 'client_script': None, 'modified': '2010-09-20 14:06:57', 'server_code_error': ' ', 'name_case': '', 'parenttype': None, 'read_only_onload': None, 'server_code_core': None, 'server_code_compiled': None, 'parent_node': None, 'parentfield': None}]
\ No newline at end of file
diff --git a/tools/doctype/rating_widget_record/__init__.py b/tools/doctype/rating_widget_record/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tools/doctype/rating_widget_record/__init__.py
diff --git a/tools/doctype/rating_widget_record/rating_widget_record.txt b/tools/doctype/rating_widget_record/rating_widget_record.txt
new file mode 100644
index 0000000..6c6a0f3
--- /dev/null
+++ b/tools/doctype/rating_widget_record/rating_widget_record.txt
@@ -0,0 +1 @@
+[{'section_style': 'Simple', 'is_transaction_doc': None, 'creation': '2009-11-12 18:16:40', 'search_fields': None, 'module': 'Tools', 'doctype': 'DocType', 'change_log': None, 'print_outline': '', 'owner': 'Administrator', 'in_dialog': None, 'in_create': None, 'read_only': None, 'allow_email': None, 'dt_template': None, 'hide_heading': None, 'issingle': None, 'allow_rename': None, 'smallicon': None, 'allow_attach': None, 'show_in_menu': 0, 'max_attachments': None, 'version': 3, 'menu_index': None, 'docstatus': 0, 'allow_copy': None, 'istable': None, 'description': None, 'parent': None, 'server_code': None, 'allow_trash': None, 'allow_print': None, 'autoname': 'RWR/.#####', 'client_script_core': None, 'client_string': None, 'use_template': None, 'modified_by': 'Administrator', 'document_type': None, 'name': 'Rating Widget Record', 'idx': None, 'hide_toolbar': None, 'colour': 'White:FFF', 'client_script': None, 'modified': '2010-09-20 14:06:57', 'server_code_error': ' ', 'name_case': '', 'parenttype': None, 'read_only_onload': None, 'server_code_core': None, 'server_code_compiled': None, 'parent_node': None, 'parentfield': None}, {'cancel': None, 'amend': None, 'execute': None, 'modified_by': 'Administrator', 'name': 'PERM00517', 'parent': 'Rating Widget Record', 'read': 1, 'create': 1, 'creation': '2009-11-12 18:16:40', 'modified': '2010-08-06 01:20:33', 'submit': None, 'doctype': 'DocPerm', 'write': 1, 'idx': 1, 'parenttype': 'DocType', 'role': 'Administrator', 'owner': 'Administrator', 'docstatus': 0, 'permlevel': 0, 'match': None, 'parentfield': 'permissions'}, {'no_copy': None, 'oldfieldtype': 'Int', 'creation': '2009-11-12 18:16:40', 'doctype': 'DocField', 'oldfieldname': 'rating_stars', 'owner': 'Administrator', 'reqd': None, 'in_filter': None, 'print_hide': None, 'modified_by': 'Administrator', 'label': 'Rating Stars', 'width': None, 'trigger': None, 'depends_on': None, 'docstatus': 0, 'hidden': None, 'permlevel': 0, 'description': None, 'parent': 'Rating Widget Record', 'search_index': None, 'allow_on_submit': None, 'icon': None, 'name': 'FL03342', 'idx': 1, 'default': None, 'colour': None, 'modified': '2010-08-06 01:20:33', 'parenttype': 'DocType', 'fieldname': 'rating_stars', 'fieldtype': 'Int', 'options': None, 'report_hide': None, 'parentfield': 'fields'}, {'no_copy': None, 'oldfieldtype': 'Data', 'creation': '2009-11-12 18:16:40', 'doctype': 'DocField', 'oldfieldname': 'rating_description', 'owner': 'Administrator', 'reqd': None, 'in_filter': None, 'print_hide': None, 'modified_by': 'Administrator', 'label': 'Rating Description', 'width': None, 'trigger': None, 'depends_on': None, 'docstatus': 0, 'hidden': None, 'permlevel': 0, 'description': None, 'parent': 'Rating Widget Record', 'search_index': None, 'allow_on_submit': None, 'icon': None, 'name': 'FL03343', 'idx': 2, 'default': None, 'colour': None, 'modified': '2010-08-06 01:20:33', 'parenttype': 'DocType', 'fieldname': 'rating_description', 'fieldtype': 'Data', 'options': None, 'report_hide': None, 'parentfield': 'fields'}, {'no_copy': None, 'oldfieldtype': 'Data', 'creation': '2009-11-12 18:16:40', 'doctype': 'DocField', 'oldfieldname': 'rating_template', 'owner': 'Administrator', 'reqd': None, 'in_filter': None, 'print_hide': None, 'modified_by': 'Administrator', 'label': 'Rating Template', 'width': None, 'trigger': None, 'depends_on': None, 'docstatus': 0, 'hidden': None, 'permlevel': 0, 'description': None, 'parent': 'Rating Widget Record', 'search_index': None, 'allow_on_submit': None, 'icon': None, 'name': 'FL03344', 'idx': 3, 'default': None, 'colour': None, 'modified': '2010-08-06 01:20:33', 'parenttype': 'DocType', 'fieldname': 'rating_template', 'fieldtype': 'Data', 'options': None, 'report_hide': None, 'parentfield': 'fields'}, {'no_copy': None, 'oldfieldtype': 'Data', 'creation': '2009-11-12 18:16:40', 'doctype': 'DocField', 'oldfieldname': 'rating_by', 'owner': 'Administrator', 'reqd': None, 'in_filter': None, 'print_hide': None, 'modified_by': 'Administrator', 'label': 'Rating By', 'width': None, 'trigger': None, 'depends_on': None, 'docstatus': 0, 'hidden': None, 'permlevel': 0, 'description': None, 'parent': 'Rating Widget Record', 'search_index': None, 'allow_on_submit': None, 'icon': None, 'name': 'FL03345', 'idx': 4, 'default': None, 'colour': None, 'modified': '2010-08-06 01:20:33', 'parenttype': 'DocType', 'fieldname': 'rating_by', 'fieldtype': 'Data', 'options': None, 'report_hide': None, 'parentfield': 'fields'}, {'no_copy': None, 'oldfieldtype': 'Data', 'creation': '2009-11-12 18:16:40', 'doctype': 'DocField', 'oldfieldname': 'rating_to', 'owner': 'Administrator', 'reqd': None, 'in_filter': None, 'print_hide': None, 'modified_by': 'Administrator', 'label': 'Rating To', 'width': None, 'trigger': None, 'depends_on': None, 'docstatus': 0, 'hidden': None, 'permlevel': 0, 'description': None, 'parent': 'Rating Widget Record', 'search_index': None, 'allow_on_submit': None, 'icon': None, 'name': 'FL03346', 'idx': 5, 'default': None, 'colour': None, 'modified': '2010-08-06 01:20:33', 'parenttype': 'DocType', 'fieldname': 'rating_to', 'fieldtype': 'Data', 'options': None, 'report_hide': None, 'parentfield': 'fields'}, {'no_copy': None, 'oldfieldtype': 'Date', 'creation': '2009-11-12 18:16:40', 'doctype': 'DocField', 'oldfieldname': 'rating_date', 'owner': 'Administrator', 'reqd': None, 'in_filter': None, 'print_hide': None, 'modified_by': 'Administrator', 'label': 'Rating Date', 'width': None, 'trigger': None, 'depends_on': None, 'docstatus': 0, 'hidden': None, 'permlevel': 0, 'description': None, 'parent': 'Rating Widget Record', 'search_index': None, 'allow_on_submit': None, 'icon': None, 'name': 'FL03347', 'idx': 6, 'default': None, 'colour': None, 'modified': '2010-08-06 01:20:33', 'parenttype': 'DocType', 'fieldname': 'rating_date', 'fieldtype': 'Date', 'options': None, 'report_hide': None, 'parentfield': 'fields'}, {'no_copy': None, 'oldfieldtype': 'Data', 'creation': '2009-11-12 18:16:40', 'doctype': 'DocField', 'oldfieldname': 'rating_time', 'owner': 'Administrator', 'reqd': None, 'in_filter': None, 'print_hide': None, 'modified_by': 'Administrator', 'label': 'Rating Time', 'width': None, 'trigger': None, 'depends_on': None, 'docstatus': 0, 'hidden': None, 'permlevel': 0, 'description': None, 'parent': 'Rating Widget Record', 'search_index': None, 'allow_on_submit': None, 'icon': None, 'name': 'FL03348', 'idx': 7, 'default': None, 'colour': None, 'modified': '2010-08-06 01:20:33', 'parenttype': 'DocType', 'fieldname': 'rating_time', 'fieldtype': 'Data', 'options': None, 'report_hide': None, 'parentfield': 'fields'}, {'no_copy': None, 'oldfieldtype': 'Data', 'creation': '2009-11-12 18:16:40', 'doctype': 'DocField', 'oldfieldname': 'rating_doctype', 'owner': 'Administrator', 'reqd': None, 'in_filter': None, 'print_hide': None, 'modified_by': 'Administrator', 'label': 'Rating Doctype', 'width': None, 'trigger': None, 'depends_on': None, 'docstatus': 0, 'hidden': None, 'permlevel': 0, 'description': None, 'parent': 'Rating Widget Record', 'search_index': None, 'allow_on_submit': None, 'icon': None, 'name': 'FL03349', 'idx': 8, 'default': None, 'colour': None, 'modified': '2010-08-06 01:20:33', 'parenttype': 'DocType', 'fieldname': 'rating_doctype', 'fieldtype': 'Data', 'options': None, 'report_hide': None, 'parentfield': 'fields'}, {'no_copy': None, 'oldfieldtype': 'Data', 'creation': '2009-11-12 18:16:40', 'doctype': 'DocField', 'oldfieldname': 'rating_docname', 'owner': 'Administrator', 'reqd': None, 'in_filter': None, 'print_hide': None, 'modified_by': 'Administrator', 'label': 'Rating Docname', 'width': None, 'trigger': None, 'depends_on': None, 'docstatus': 0, 'hidden': None, 'permlevel': 0, 'description': None, 'parent': 'Rating Widget Record', 'search_index': None, 'allow_on_submit': None, 'icon': None, 'name': 'FL03350', 'idx': 9, 'default': None, 'colour': None, 'modified': '2010-08-06 01:20:33', 'parenttype': 'DocType', 'fieldname': 'rating_docname', 'fieldtype': 'Data', 'options': None, 'report_hide': None, 'parentfield': 'fields'}]
\ No newline at end of file
diff --git a/tools/doctype/receiver_detail/__init__.py b/tools/doctype/receiver_detail/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tools/doctype/receiver_detail/__init__.py
diff --git a/tools/doctype/receiver_detail/receiver_detail.txt b/tools/doctype/receiver_detail/receiver_detail.txt
new file mode 100644
index 0000000..62d7ca2
--- /dev/null
+++ b/tools/doctype/receiver_detail/receiver_detail.txt
@@ -0,0 +1 @@
+[{'section_style': 'Tray', 'is_transaction_doc': None, 'creation': '2009-03-12 17:10:13', 'search_fields': None, 'module': 'Tools', 'doctype': 'DocType', 'change_log': None, 'print_outline': '', 'owner': 'Administrator', 'in_dialog': None, 'in_create': None, 'read_only': None, 'allow_email': None, 'dt_template': None, 'hide_heading': None, 'issingle': None, 'allow_rename': None, 'smallicon': '', 'allow_attach': None, 'show_in_menu': None, 'max_attachments': None, 'version': 2, 'menu_index': None, 'docstatus': 0, 'allow_copy': None, 'istable': 1, 'description': None, 'parent': None, 'server_code': None, 'allow_trash': None, 'allow_print': None, 'autoname': None, 'client_script_core': None, 'client_string': None, 'use_template': None, 'modified_by': 'Administrator', 'document_type': None, 'name': 'Receiver Detail', 'idx': None, 'hide_toolbar': None, 'colour': 'White:FFF', 'client_script': None, 'modified': '2010-09-20 14:06:57', 'server_code_error': ' ', 'name_case': '', 'parenttype': None, 'read_only_onload': None, 'server_code_core': None, 'server_code_compiled': None, 'parent_node': None, 'parentfield': None}, {'no_copy': None, 'oldfieldtype': 'Data', 'creation': '2010-07-05 13:29:27', 'doctype': 'DocField', 'oldfieldname': 'customer_name', 'owner': 'Administrator', 'reqd': None, 'in_filter': None, 'print_hide': None, 'modified_by': 'Administrator', 'label': 'Customer Name', 'width': None, 'trigger': None, 'depends_on': None, 'docstatus': 0, 'hidden': None, 'permlevel': 0, 'description': None, 'parent': 'Receiver Detail', 'search_index': None, 'allow_on_submit': None, 'icon': None, 'name': 'FL05519', 'idx': 1, 'default': None, 'colour': None, 'modified': '2010-07-05 13:29:27', 'parenttype': 'DocType', 'fieldname': 'customer_name', 'fieldtype': 'Data', 'options': None, 'report_hide': None, 'parentfield': 'fields'}, {'no_copy': None, 'oldfieldtype': 'Data', 'creation': '2009-03-12 17:10:13', 'doctype': 'DocField', 'oldfieldname': 'receiver_name', 'owner': 'Administrator', 'reqd': None, 'in_filter': None, 'print_hide': None, 'modified_by': 'Administrator', 'label': 'Receiver Name', 'width': '350px', 'trigger': None, 'depends_on': None, 'docstatus': 0, 'hidden': None, 'permlevel': 0, 'description': None, 'parent': 'Receiver Detail', 'search_index': None, 'allow_on_submit': None, 'icon': None, 'name': 'FL01344', 'idx': 2, 'default': None, 'colour': None, 'modified': '2010-07-05 13:29:27', 'parenttype': 'DocType', 'fieldname': 'receiver_name', 'fieldtype': 'Data', 'options': None, 'report_hide': None, 'parentfield': 'fields'}, {'no_copy': None, 'oldfieldtype': 'Data', 'creation': '2009-03-12 17:10:13', 'doctype': 'DocField', 'oldfieldname': 'mobile_no', 'owner': 'Administrator', 'reqd': 1, 'in_filter': None, 'print_hide': None, 'modified_by': 'Administrator', 'label': 'Mobile No', 'width': '200px', 'trigger': None, 'depends_on': None, 'docstatus': 0, 'hidden': None, 'permlevel': 0, 'description': None, 'parent': 'Receiver Detail', 'search_index': None, 'allow_on_submit': None, 'icon': None, 'name': 'FL01345', 'idx': 3, 'default': None, 'colour': None, 'modified': '2010-07-05 13:29:27', 'parenttype': 'DocType', 'fieldname': 'mobile_no', 'fieldtype': 'Data', 'options': None, 'report_hide': None, 'parentfield': 'fields'}]
\ No newline at end of file
diff --git a/tools/doctype/reposting_tool/__init__.py b/tools/doctype/reposting_tool/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tools/doctype/reposting_tool/__init__.py
diff --git a/tools/doctype/reposting_tool/reposting_tool.js b/tools/doctype/reposting_tool/reposting_tool.js
new file mode 100644
index 0000000..8a1d41f
--- /dev/null
+++ b/tools/doctype/reposting_tool/reposting_tool.js
@@ -0,0 +1,63 @@
+var bin_list = [];
+var msg = [];
+var binidx = 0;
+
+cur_frm.cscript['Repost Bin'] = function(doc,cdt,cdn) {
+ args = {'check': 'Bin'};
+ $c_obj('Reposting Tool','get_count_for_reposting', docstring(args), function(r,rt) {
+ bin_list = r.message;
+ repair_bin();
+ });
+}
+
+function repair_single_bin(){
+ $c_obj('Reposting Tool', 'repair_bin', cstr(bin_list[binidx]), function(r,rt) {
+ for(i = 0; i < r.message.length ; i++){
+ msg.push(r.message[i]);
+ }
+ repair_bin();
+ });
+}
+
+function repair_bin(){
+ if(binidx >= 10) {
+ args = {'msg': msg, 'subject': 'Item Quantity'};
+ $c_obj('Reposting Tool', 'send_mail', docstring(args));
+ alert('Completed');
+ return;
+ }
+ repair_single_bin();
+ binidx ++;
+}
+
+// Batch for Account Balances
+//======================================================
+var acc_list = [];
+var accidx = 0;
+cur_frm.cscript['Repost Account Balances'] = function(doc,cdt,cdn) {
+ args = {'check': 'Account Balance'};
+ $c_obj('Reposting Tool','get_count_for_reposting', docstring(args), function(r,rt) {
+ acc_list = r.message;
+ repair_acc_bal();
+ });
+}
+
+function repair_single_acc_bal(){
+ $c_obj('Reposting Tool', 'repair_acc_bal', cstr(acc_list[accidx]), function(r,rt) {
+ for(i = 0; i < r.message.length; i++){
+ msg.push(r.message[i]);
+ }
+ repair_acc_bal();
+ });
+}
+
+function repair_acc_bal(){
+ if(accidx >= 15) {
+ args = {'msg' : msg, 'subject': 'Account Balance'};
+ $c_obj('Reposting Tool', 'send_mail', docstring(args));
+ alert('Completed');
+ return;
+ }
+ repair_single_acc_bal();
+ accidx ++;
+}
\ No newline at end of file
diff --git a/tools/doctype/reposting_tool/reposting_tool.py b/tools/doctype/reposting_tool/reposting_tool.py
new file mode 100644
index 0000000..9560650
--- /dev/null
+++ b/tools/doctype/reposting_tool/reposting_tool.py
@@ -0,0 +1,156 @@
+# Please edit this list and import only required elements
+import webnotes
+
+from webnotes.utils import add_days, add_months, add_years, cint, cstr, date_diff, default_fields, flt, fmt_money, formatdate, generate_hash, getTraceback, get_defaults, get_first_day, get_last_day, getdate, has_common, month_name, now, nowdate, replace_newlines, sendmail, set_default, str_esc_quote, user_format, validate_email_add
+from webnotes.model import db_exists
+from webnotes.model.doc import Document, addchild, removechild, getchildren, make_autoname, SuperDocType
+from webnotes.model.doclist import getlist, copy_doclist
+from webnotes.model.code import get_obj, get_server_obj, run_server_obj, updatedb, check_syntax
+from webnotes import session, form, is_testing, msgprint, errprint
+
+set = webnotes.conn.set
+sql = webnotes.conn.sql
+get_value = webnotes.conn.get_value
+in_transaction = webnotes.conn.in_transaction
+convert_to_lists = webnotes.conn.convert_to_lists
+
+# -----------------------------------------------------------------------------------------
+
+
+class DocType:
+ def __init__(self, doc, doclist=[]):
+ self.doc = doc
+ self.doclist = doclist
+ self.msg = []
+
+ def get_count_for_reposting(self, args):
+ args = eval(args)
+ if args['check'] == 'Bin':
+ return [d[0] for d in sql("select name from `tabBin` where item_code = 'Repost Item' " )]
+
+ if args['check'] == 'Account Balance':
+ # message
+ if not self.doc.past_year:
+ msgprint('<div style="color: ORANGE"> Warning: Opening balances were not imported </div>')
+
+ # do not repost from same year
+ if self.doc.past_year == self.doc.name:
+ msgprint("Cannot import from the current year")
+
+ return [d[0] for d in sql("select name from `tabAccount` ")]
+
+ def get_bin_qty(self, wh, item):
+ # get actual_qty
+ act_qty = sql("select ifnull(actual_qty, 0) from `tabBin` where warehouse = '%s' and item_code = '%s'" % (wh, item))
+ act_qty = act_qty and flt(act_qty[0][0]) or 0
+
+ # get indented_qty
+ ind_qty = sql("select sum(if( ifnull(t2.qty, 0) > ifnull(t2.ordered_qty, 0), ifnull(t2.qty, 0) - ifnull(t2.ordered_qty, 0), 0) ) from `tabIndent` t1, `tabIndent Detail`t2 where t1.name = t2.parent and t1.docstatus = 1 and t2.warehouse = '%s' and t2.item_code = '%s'" % (wh, item))
+ ind_qty = ind_qty and flt(ind_qty[0][0]) or 0
+
+ # get ordered_qty
+ ord_qty = sql("select sum(if ( ifnull(t2.qty, 0) > ifnull(t2.received_qty, 0), (ifnull(t2.qty, 0) - ifnull(t2.received_qty, 0)) * ifnull(t2.conversion_factor, 0) , 0) ) from `tabPurchase Order` t1, `tabPO Detail` t2 where t1.name = t2.parent and t1.docstatus = 1 and t2.warehouse = '%s' and t2.item_code = '%s'" % (wh, item))
+ ord_qty = ord_qty and flt(ord_qty[0][0]) or 0
+
+ # get reserved_qty
+ res_qty =sql("select sum(if ( ifnull(t2.qty, 0) > ifnull(t2.delivered_qty, 0), ifnull(t2.qty, 0) - ifnull(t2.delivered_qty, 0) , 0) ) from `tabSales Order` t1, `tabSales Order Detail` t2 where t1.name = t2.parent and t1.docstatus = 1 and t2.reserved_warehouse = '%s' and t2.item_code = '%s' " % (wh, item))
+ res_qty = res_qty and flt(res_qty[0][0]) or 0
+
+ # get planned_qty
+ plan_qty = sql("select sum(if ( ifnull(qty, 0) > ifnull(produced_qty,0), ifnull(qty, 0) - ifnull(produced_qty, 0), 0) ) from `tabProduction Order` where fg_warehouse = '%s' and production_item = '%s' and docstatus = 1" % (wh, item))
+ plan_qty = plan_qty and flt(plan_qty[0][0]) or 0
+
+ return {'actual_qty': act_qty, 'indented_qty': ind_qty, 'ordered_qty': ord_qty, 'reserved_qty': res_qty, 'planned_qty': plan_qty }
+
+ def check_bin_qty(self, bin_obj, qty_dict):
+ label_dict = {'actual_qty': 'Actual Qty', 'indented_qty': 'Indent Qty', 'ordered_qty': 'Ordered Qty', 'reserved_qty': 'Reserved Qty', 'planned_qty': 'Planned Qty'}
+ for f in qty_dict:
+ if flt(bin_obj.doc.fields[f]) != qty_dict[f]:
+ msgprint('<div style="color: RED"> Difference found in %s for Item:= %s and Warehouse:= %s (Before : %s; After : %s)</div>' % (label_dict[f], bin_obj.doc.item_code, bin_obj.doc.warehouse, cstr(bin_obj.doc.fields[f]), cstr(qty_dict[f])))
+ self.msg.append('<div style="color: RED"> Difference found in %s for Item:= %s and Warehouse:= %s (Before : %s; After : %s)</div>' % (label_dict[f], bin_obj.doc.item_code, bin_obj.doc.warehouse, cstr(bin_obj.doc.fields[f]), cstr(qty_dict[f])))
+
+ # Check projected qty
+ projected_qty = flt(qty_dict['actual_qty']) + flt(qty_dict['indented_qty']) + flt(qty_dict['ordered_qty']) + flt(qty_dict['planned_qty']) - flt(qty_dict['reserved_qty'])
+ if flt(projected_qty) != flt(bin_obj.doc.projected_qty):
+ msgprint('<div style="color: RED">Difference found in Projected Qty for Item:= %s and Warehouse:= %s (Before : %s; After : %s)</div>' % (bin_obj.doc.item_code, bin_obj.doc.warehouse, bin_obj.doc.projected_qty, cstr(projected_qty)))
+ self.msg.append('<div style="color: RED">Difference found in Projected Qty for Item:= %s and Warehouse:= %s (Before : %s; After : %s)</div>' % (bin_obj.doc.item_code, bin_obj.doc.warehouse, bin_obj.doc.projected_qty, cstr(projected_qty)))
+
+ def repair_bin(self, bin):
+ import webnotes
+ bin_obj = get_obj('Bin',bin)
+ bin_act_qty = flt(bin_obj.doc.actual_qty)
+ try:
+ # udpate actual qty and item valuation
+ bin_obj.update_item_valuation('', '2000-01-01', '00:00')
+ # get bin qty
+ qty_dict = self.get_bin_qty(bin_obj.doc.warehouse, bin_obj.doc.item_code)
+
+ # check bin qty
+ self.check_bin_qty(bin_obj, qty_dict)
+
+ # update indented_qty, ordered_qty, reserved_qty, planned_qty
+ sql("update `tabBin` set indented_qty = '%s', ordered_qty = '%s', reserved_qty = '%s', planned_qty = '%s' where warehouse = '%s' and item_code = '%s'" % ( flt(qty_dict['indented_qty']), flt(qty_dict['ordered_qty']), flt(qty_dict['reserved_qty']), flt(qty_dict['planned_qty']), bin_obj.doc.warehouse, bin_obj.doc.item_code))
+
+ # update projected_qty
+ sql("update `tabBin` set projected_qty = ifnull(indented_qty, 0) + ifnull(ordered_qty,0) + ifnull(actual_qty, 0) + ifnull(planned_qty, 0) - ifnull(reserved_qty,0) where warehouse = '%s' and item_code = '%s' " % (bin_obj.doc.warehouse, bin_obj.doc.item_code))
+ if not self.msg:
+ msgprint('<div style="color: GREEN"> Reposting of Stock for Item %s and Warehouse %s completed Successfully. </div>' % (bin_obj.doc.item_code, bin_obj.doc.warehouse))
+ except Exception:
+ msgprint('<div style="color: RED"> Handle Item %s and Warehouse %s seprately. </div> <div style="color: RED"> ERROR: %s</div>' % (bin_obj.doc.item_code, bin_obj.doc.warehouse, str(webnotes.utils.getTraceback())))
+ self.msg.append('<div style="color: RED"> ERROR: %s</div>' % (str(webnotes.utils.getTraceback())))
+
+ def repair_opening_bal(self, d, acc_obj, past_yr, fiscal_yr):
+ # check opening balance
+ opbal = sql("select balance from `tabAccount Balance` where account=%s and period = %s", (acc_obj.doc.name, past_yr))
+ if flt(d.opening) != flt(opbal and flt(opbal[0][0]) or 0):
+ msgprint('<div style="color: RED"> Difference found in Opening of Account %s for Period %s in Fiscal Year %s (Before : %s; After : %s) </div>' % (acc_obj.doc.name, d.period, fiscal_yr, flt(d.opening), opbal and flt(opbal[0][0]) or 0))
+ self.msg.append('<div style="color: RED"> Difference found in Opening of Account %s for Period %s in Fiscal Year %s (Before : %s; After : %s) </div>' % (acc_obj.doc.name, d.period, fiscal_yr, flt(d.opening), opbal and flt(opbal[0][0]) or 0))
+ sql("update `tabAccount Balance` set opening = '%s' where period = '%s' and account = '%s' " % (opbal and flt(opbal[0][0]) or 0, fiscal_yr, acc_obj.doc.name))
+
+ def repair_bal(self, d, acc_obj, fiscal_yr):
+ # check balances
+ ysd = get_value('Fiscal Year', fiscal_yr, 'year_start_date')
+ bal = get_obj('GL Control').get_as_on_balance(acc_obj.doc.name, fiscal_yr, d.end_date, acc_obj.doc.debit_or_credit, acc_obj.doc.is_pl_account, acc_obj.doc.lft, acc_obj.doc.rgt, ysd)
+ if flt(d.balance) != flt(bal):
+ msgprint('<div style="color: RED"> Difference found in Balance of Account %s for Period %s in Fiscal Year %s (Before : %s; After : %s) </div>' % (acc_obj.doc.name, d.period, fiscal_yr, flt(d.balance), flt(bal)))
+ self.msg.append('<div style="color: RED"> Difference found in Balance of Account %s for Period %s in Fiscal Year %s (Before : %s; After : %s) </div>' % (acc_obj.doc.name, d.period, fiscal_yr, flt(d.balance), flt(bal)))
+ sql("update `tabAccount Balance` set balance = '%s' where period = '%s' and account = '%s' " % (bal, d.period, acc_obj.doc.name))
+
+ def repair_acc_bal(self, acc, past_yr = '' , fiscal_yr = ''):
+ # get account obj
+ acc_obj = get_obj('Account', acc, with_children = 1)
+
+ # get fiscal yr & past yr
+ if not fiscal_yr:
+ import webnotes.utils
+ fiscal_yr = webnotes.utils.get_defaults()['fiscal_year']
+ if not past_yr: past_yr = get_value('Fiscal Year', fiscal_yr, 'past_year')
+
+ # Repair Opening and Balance For Account Balances
+ for d in getlist(acc_obj.doclist, 'account_balances'):
+ if d.fiscal_year == fiscal_yr:
+ if past_yr and (past_yr != fiscal_yr) and d.period == fiscal_yr:
+ self.repair_opening_bal(d, acc_obj, past_yr, fiscal_yr)
+ else:
+ self.repair_bal(d, acc_obj, fiscal_yr)
+
+ # Acknowledge USer
+ if not self.msg:
+ msgprint('<div style="color: GREEN"> Openings & Balances of Account %s for Fiscal Year %s updated successfully. </div>' % ( acc_obj.doc.name, fiscal_yr))
+
+ return self.msg
+
+ def send_mail(self, args):
+ args = eval(args)
+ self.msg, subject = args['msg'], args['subject']
+ msgprint(self.msg)
+ if self.msg:
+ email_msg = """ Dear Administrator,
+
+In Account := %s User := %s has Reposted %s and following was found:-
+
+%s
+
+""" % (get_value('Control Panel', None,'account_id'), session['user'], subject, '\n'.join(self.msg))
+
+ sendmail(['saumil@iwebnotes.com','nabin@iwebnotes.com'], subject='Repair of ' + cstr(subject), parts = [('text/plain', email_msg)])
diff --git a/tools/doctype/reposting_tool/reposting_tool.txt b/tools/doctype/reposting_tool/reposting_tool.txt
new file mode 100644
index 0000000..9673e3a
--- /dev/null
+++ b/tools/doctype/reposting_tool/reposting_tool.txt
@@ -0,0 +1 @@
+[{'section_style': 'Simple', 'is_transaction_doc': None, 'creation': '2010-04-13 09:24:32', 'search_fields': None, 'module': 'Tools', 'doctype': 'DocType', 'change_log': None, 'print_outline': '', 'owner': 'Administrator', 'in_dialog': None, 'in_create': 0, 'read_only': 1, 'allow_email': 1, 'dt_template': None, 'hide_heading': None, 'issingle': 1, 'allow_rename': None, 'smallicon': None, 'allow_attach': None, 'show_in_menu': None, 'max_attachments': None, 'version': 173, 'menu_index': None, 'docstatus': 0, 'allow_copy': 1, 'istable': None, 'description': None, 'parent': None, 'server_code': None, 'allow_trash': None, 'allow_print': 1, 'autoname': None, 'client_script_core': None, 'client_string': None, 'use_template': None, 'modified_by': 'saumil@webnotestech.com', 'document_type': '', 'name': 'Reposting Tool', 'idx': None, 'hide_toolbar': 1, 'colour': 'Light Blue:DEF', 'client_script': None, 'modified': '2010-10-14 12:15:59', 'server_code_error': ' ', 'name_case': '', 'parenttype': None, 'read_only_onload': None, 'server_code_core': None, 'server_code_compiled': None, 'parent_node': None, 'parentfield': None}, {'cancel': None, 'amend': None, 'execute': None, 'modified_by': 'saumil@webnotestech.com', 'name': 'PERM00769', 'parent': 'Reposting Tool', 'read': 1, 'create': 1, 'creation': '2010-04-13 09:24:32', 'modified': '2010-10-14 12:15:59', 'submit': None, 'doctype': 'DocPerm', 'write': 1, 'idx': 1, 'parenttype': 'DocType', 'role': 'Administrator', 'owner': 'Administrator', 'docstatus': 0, 'permlevel': 0, 'match': None, 'parentfield': 'permissions'}, {'no_copy': None, 'oldfieldtype': None, 'creation': '2010-04-13 09:24:32', 'doctype': 'DocField', 'oldfieldname': None, 'owner': 'Administrator', 'reqd': None, 'in_filter': None, 'print_hide': None, 'modified_by': 'saumil@webnotestech.com', 'label': 'Recalculate MAR & Actual Qty', 'width': None, 'trigger': None, 'depends_on': None, 'docstatus': 0, 'hidden': None, 'permlevel': 0, 'description': None, 'parent': 'Reposting Tool', 'search_index': None, 'allow_on_submit': None, 'icon': None, 'name': 'FL04638', 'idx': 1, 'default': None, 'colour': None, 'modified': '2010-10-14 12:15:59', 'parenttype': 'DocType', 'fieldname': 'recalculate_mar_&_actual_qty', 'fieldtype': 'Data', 'options': None, 'report_hide': None, 'parentfield': 'fields'}, {'no_copy': None, 'oldfieldtype': None, 'creation': '2010-07-28 13:34:48', 'doctype': 'DocField', 'oldfieldname': None, 'owner': 'jai@webnotestech.com', 'reqd': None, 'in_filter': None, 'print_hide': None, 'modified_by': 'saumil@webnotestech.com', 'label': 'Repost Bin', 'width': None, 'trigger': 'Client', 'depends_on': None, 'docstatus': 0, 'hidden': None, 'permlevel': 0, 'description': None, 'parent': 'Reposting Tool', 'search_index': None, 'allow_on_submit': None, 'icon': None, 'name': 'FL05722', 'idx': 2, 'default': None, 'colour': 'White:FFF', 'modified': '2010-10-14 12:15:59', 'parenttype': 'DocType', 'fieldname': None, 'fieldtype': 'Button', 'options': None, 'report_hide': None, 'parentfield': 'fields'}, {'no_copy': None, 'oldfieldtype': None, 'creation': '2010-07-30 09:22:26', 'doctype': 'DocField', 'oldfieldname': None, 'owner': 'jai@webnotestech.com', 'reqd': None, 'in_filter': None, 'print_hide': None, 'modified_by': 'saumil@webnotestech.com', 'label': 'Repost Account Balances', 'width': None, 'trigger': 'Client', 'depends_on': None, 'docstatus': 0, 'hidden': None, 'permlevel': 0, 'description': None, 'parent': 'Reposting Tool', 'search_index': None, 'allow_on_submit': None, 'icon': None, 'name': 'FL05758', 'idx': 3, 'default': None, 'colour': None, 'modified': '2010-10-14 12:15:59', 'parenttype': 'DocType', 'fieldname': None, 'fieldtype': 'Button', 'options': None, 'report_hide': None, 'parentfield': 'fields'}]
\ No newline at end of file
diff --git a/tools/doctype/sms_control/__init__.py b/tools/doctype/sms_control/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tools/doctype/sms_control/__init__.py
diff --git a/tools/doctype/sms_control/sms_control.js b/tools/doctype/sms_control/sms_control.js
new file mode 100644
index 0000000..c6cc53e
--- /dev/null
+++ b/tools/doctype/sms_control/sms_control.js
@@ -0,0 +1,93 @@
+function SMSManager() {
+ var me = this;
+ this.get_contact_number = function(contact, key, value) {
+ $c_obj('SMS Control', 'get_contact_number', {
+ contact_name:contact,
+ value:value,
+ key:key
+ }, function(r,rt) {
+ if(r.exc) { msgprint(r.exc); return; }
+ me.number = r.message;
+ me.show_dialog();
+ }
+ );
+ }
+ this.show = function(contact, key, value, mobile_nos, message) {
+ this.message = message;
+ if (mobile_nos) {
+
+ me.number = mobile_nos;
+ me.show_dialog();
+ } else if (contact){
+ this.get_contact_number(contact, key, value)
+ } else {
+ me.show_dialog();
+ }
+ }
+ this.show_dialog = function() {
+ if(!me.dialog)
+ me.make_dialog();
+ me.dialog.set_values({
+ 'message': me.message,
+ 'number': me.number
+ })
+ me.dialog.show();
+ }
+ this.make_dialog = function() {
+ var d = new wn.widgets.Dialog({
+ title: 'Send SMS',
+ width: 400,
+ fields: [
+ {fieldname:'number', fieldtype:'Data', label:'Mobile Number', reqd:1},
+ {fieldname:'message', fieldtype:'Text', label:'Message', reqd:1},
+ {fieldname:'send', fieldtype:'Button', label:'Send'}
+ ]
+ })
+ d.make();
+ d.fields_dict.send.input.onclick = function() {
+ var btn = d.fields_dict.send.input;
+ var v = me.dialog.get_values();
+ if(v) {
+ btn.set_working();
+ $c_obj('SMS Control', 'send_form_sms', v, function(r,rt) {
+ btn.done_working();
+ if(r.exc) {msgprint(r.exc); return; }
+ msgprint('Message Sent');
+ me.dialog.hide();
+ })
+ }
+ }
+ this.dialog = d;
+ }
+}
+
+cur_frm.cscript['Send SMS'] = function(doc,dt,dn) {
+ var doc = cur_frm.doc;
+ var sms_man = new SMSManager();
+ var default_msg = {
+ 'Lead' : '',
+ 'Enquiry' : 'Your enquiry has been logged into the system. Ref No: ' + doc.name,
+ 'Quotation' : 'Quotation ' + doc.name + ' has been sent via email. Thanks!',
+ 'Sales Order' : 'Sales Order ' + doc.name + ' has been created against '
+ + (doc.quotation_no ? ('Quote No:' + doc.quotation_no) : '')
+ + (doc.po_no ? (' for your PO: ' + doc.po_no) : ''),
+ 'Delivery Note' : 'Items has been delivered against delivery note: ' + doc.name
+ + (doc.po_no ? (' for your PO: ' + doc.po_no) : ''),
+ 'Receivable Voucher': 'Invoice ' + doc.name + ' has been sent via email '
+ + (doc.po_no ? (' for your PO: ' + doc.po_no) : ''),
+ 'Indent' : 'Indent ' + doc.name + ' has been raised in the system',
+ 'Purchase Order' : 'Purchase Order ' + doc.name + ' has been sent via email',
+ 'Purchase Receipt' : 'Items has been received against purchase receipt: ' + doc.name
+ }
+
+ if (in_list(['Quotation', 'Sales Order', 'Delivery Note', 'Receivable Voucher'], doc.doctype))
+ sms_man.show(doc.contact_person, 'customer', doc.customer, '', default_msg[doc.doctype]);
+ else if (in_list(['Purchase Order', 'Purchase Receipt'], doc.doctype))
+ sms_man.show(doc.contact_person, 'supplier', doc.supplier, '', default_msg[doc.doctype]);
+ else if (doc.doctype == 'Lead')
+ sms_man.show('', '', '', doc.mobile_no, default_msg[doc.doctype]);
+ else if (doc.doctype == 'Enquiry')
+ sms_man.show('', '', '', doc.contact_no, default_msg[doc.doctype]);
+ else if (doc.doctype == 'Indent')
+ sms_man.show('', '', '', '', default_msg[doc.doctype]);
+}
diff --git a/tools/doctype/sms_control/sms_control.py b/tools/doctype/sms_control/sms_control.py
new file mode 100644
index 0000000..de11e90
--- /dev/null
+++ b/tools/doctype/sms_control/sms_control.py
@@ -0,0 +1,190 @@
+# Please edit this list and import only required elements
+import webnotes
+
+from webnotes.utils import cint, flt, load_json, nowdate, cstr
+from webnotes.model.code import get_obj
+from webnotes.model.doc import Document
+from webnotes import session, msgprint
+from webnotes.model.doclist import getlist, copy_doclist
+
+sql = webnotes.conn.sql
+get_value = webnotes.conn.get_value
+
+# -----------------------------------------------------------------------------------------
+class DocType:
+ def __init__(self, doc, doclist=[]):
+ self.doc = doc
+ self.doclist = doclist
+
+ # validate receiver numbers
+ # =========================================================
+ def validate_receiver_nos(self,receiver_list):
+ validated_receiver_list = []
+ for d in receiver_list:
+ # remove invalid character
+ invalid_char_list = [' ', '+', '-', '(', ')']
+ for x in invalid_char_list:
+ d = d.replace(x, '')
+
+ # mobile no validation for erpnext gateway
+ if get_value('SMS Settings', None, 'sms_gateway_url'):
+ mob_no = d
+ else:
+ if not d.startswith("0") and len(d) == 10:
+ mob_no = "91" + d
+ elif d.startswith("0") and len(d) == 11:
+ mob_no = "91" + d[1:]
+ elif len(d) == 12:
+ mob_no = d
+ else:
+ msgprint("Invalid mobile no : " + cstr(d))
+ raise Exception
+
+ if not mob_no.isdigit():
+ msgprint("Invalid mobile no : " + cstr(mob_no))
+ raise Exception
+
+ validated_receiver_list.append(mob_no)
+
+ if not validated_receiver_list:
+ msgprint("Please enter valid mobile nos")
+ raise Exception
+
+ return validated_receiver_list
+
+
+ # Connect Gateway
+ # =========================================================
+ def connect_gateway(self):
+ "login to gateway"
+ from webnotes.utils.webservice import FrameworkServer
+ fw = FrameworkServer('www.erpnext.com','/','__system@webnotestech.com','password',https=1)
+ return fw
+
+ def get_sender_name(self):
+ "returns name as SMS sender"
+ return webnotes.conn.get_value('Manage Account', None, 'sms_sender_name') or 'ERPNext'
+
+ def get_contact_number(self, arg):
+ "returns mobile number of the contact"
+ args = load_json(arg)
+ number = sql('select mobile_no, phone from tabContact where name=%s and %s=%s' % ('%s', args['key'], '%s'),\
+ (args['contact_name'], args['value']))
+ return number and (number[0][0] or number[0][1]) or ''
+
+ def send_form_sms(self, arg):
+ "called from client side"
+ args = load_json(arg)
+ self.send_sms([str(args['number'])], str(args['message']))
+
+
+ # Send SMS
+ # =========================================================
+ def send_sms(self, receiver_list, msg, sender_name = ''):
+ receiver_list = self.validate_receiver_nos(receiver_list)
+
+ arg = { 'account_name' : webnotes.conn.get_value('Control Panel',None,'account_id'),
+ 'receiver_list' : receiver_list,
+ 'message' : msg,
+ 'sender_name' : sender_name or self.get_sender_name()
+ }
+
+ # personalized or erpnext gateway
+ if get_value('SMS Settings', None, 'sms_gateway_url'):
+ ret = self.send_via_personalized_gateway(arg)
+ msgprint(ret)
+ else:
+ ret = self.send_via_erpnext_gateway(arg)
+
+ # Send sms via personalized gateway
+ # ==========================================================
+ def send_via_personalized_gateway(self, arg):
+ ss = get_obj('SMS Settings', 'SMS Settings', with_children=1)
+ args = {ss.doc.message_parameter : arg.get('message')}
+ for d in getlist(ss.doclist, 'static_parameter_details'):
+ args[d.parameter] = d.value
+
+ resp = []
+ for d in arg.get('receiver_list'):
+ args[ss.doc.receiver_parameter] = d
+ resp.append(self.send_request(ss.doc.sms_gateway_url, args))
+
+ return resp
+
+ # Send sms via ERPNext gateway
+ # ==========================================================
+ def send_via_erpnext_gateway(self, arg):
+ fw = self.connect_gateway()
+ ret = fw.run_method(method = 'erpnext_utils.sms_control.send_sms', args = arg)
+
+ if ret.get('exc'):
+ msgprint(ret['exc'])
+ raise Exception
+ elif ret['message']:
+ sms_sent = cint(ret['message']['sms_sent'])
+ sms_bal = cint(ret['message']['sms_balance'])
+ self.create_sms_log(arg, ret['message']['sms_sent'])
+
+ if not sms_sent:
+ if sms_bal < len(arg['receiver_list']):
+ msgprint("You do not have enough SMS balance. Current SMS Balance: " + cstr(sms_bal) + "\nYou can send mail to sales@erpnext.com to buy additional sms packages")
+ raise Exception
+ else:
+ msgprint("Message sent failed. May be numbers are invalid or some other issues.")
+ else:
+ msgprint(cstr(sms_sent) + " message sucessfully sent!\nCurrent SMS Balance: " + cstr(cint(ret['message']['sms_balance']) - cint(ret['message']['sms_sent'])))
+
+
+ # Send Request
+ # =========================================================
+ def send_request(self, gateway_url, args):
+ import httplib, urllib
+ server, api_url = self.scrub_gateway_url(gateway_url)
+ conn = httplib.HTTPConnection(server) # open connection
+ headers = {}
+ headers['Accept'] = "text/plain, text/html, */*"
+ conn.request('GET', api_url + urllib.urlencode(args), headers = headers) # send request
+ resp = conn.getresponse() # get response
+ resp = resp.read()
+ return resp
+
+ # Split gateway url to server and api url
+ # =========================================================
+ def scrub_gateway_url(self, url):
+ url = url.replace('http://', '').strip().split('/')
+ server = url.pop(0)
+ api_url = '/' + '/'.join(url)
+ if not api_url.endswith('?'):
+ api_url += '?'
+ return server, api_url
+
+
+
+
+ # Create SMS Log
+ # =========================================================
+ def create_sms_log(self, arg, sent_sms):
+ sl = Document('SMS Log')
+ sl.sender_name = arg['sender_name']
+ sl.sent_on = nowdate()
+ sl.receiver_list = cstr(arg['receiver_list'])
+ sl.message = arg['message']
+ sl.no_of_requested_sms = len(arg['receiver_list'])
+ sl.no_of_sent_sms = sent_sms
+ sl.save(new=1)
+
+ # Get SMS Balance
+ # =========================================================
+ def get_sms_balance(self):
+ arg = { 'account_name' : webnotes.conn.get_value('Control Panel',None,'account_id') }
+ if get_value('SMS Settings', None, 'sms_gateway_url'):
+ ret = {}
+ else:
+ fw = self.connect_gateway()
+ ret = fw.run_method(mothod = 'erpnext_utils.sms_control.get_sms_balance', args = arg)
+
+ if ret.get('exc'):
+ msgprint(ret['exc'])
+ raise Exception
+ else:
+ msgprint("Current SMS Balance: " + cstr(ret['message']) + "\nYou can send mail to sales@erpnext.com to buy sms packages")
diff --git a/tools/doctype/sms_control/sms_control.txt b/tools/doctype/sms_control/sms_control.txt
new file mode 100644
index 0000000..727d41b
--- /dev/null
+++ b/tools/doctype/sms_control/sms_control.txt
@@ -0,0 +1,101 @@
+[
+ {
+ 'allow_attach': None,
+ 'allow_copy': None,
+ 'allow_email': None,
+ 'allow_print': None,
+ 'allow_rename': None,
+ 'allow_trash': None,
+ 'autoname': None,
+ 'change_log': None,
+ 'client_script': None,
+ 'client_script_core': None,
+ 'client_string': None,
+ 'colour': 'White:FFF',
+ 'creation': '2010-08-08 17:09:24',
+ 'description': None,
+ 'docstatus': 0,
+ 'doctype': 'DocType',
+ 'document_type': None,
+ 'dt_template': None,
+ 'hide_heading': None,
+ 'hide_toolbar': None,
+ 'idx': None,
+ 'in_create': 0,
+ 'in_dialog': None,
+ 'is_transaction_doc': None,
+ 'issingle': 1,
+ 'istable': None,
+ 'max_attachments': None,
+ 'menu_index': None,
+ 'modified': '2011-04-08 16:53:02',
+ 'modified_by': 'Administrator',
+ 'module': 'Tools',
+ 'name': 'SMS Control',
+ 'name_case': None,
+ 'owner': 'Administrator',
+ 'parent': None,
+ 'parent_node': '',
+ 'parentfield': None,
+ 'parenttype': None,
+ 'print_outline': None,
+ 'read_only': None,
+ 'read_only_onload': None,
+ 'search_fields': None,
+ 'section_style': 'Simple',
+ 'server_code': None,
+ 'server_code_compiled': None,
+ 'server_code_core': None,
+ 'server_code_error': ' ',
+ 'show_in_menu': 0,
+ 'smallicon': None,
+ 'use_template': None,
+ 'version': 4
+ },
+ {
+ 'amend': None,
+ 'cancel': None,
+ 'create': 1,
+ 'creation': '2010-08-08 17:09:24',
+ 'docstatus': 0,
+ 'doctype': 'DocPerm',
+ 'execute': None,
+ 'idx': 1,
+ 'match': None,
+ 'modified': '2011-04-08 16:53:02',
+ 'modified_by': 'Administrator',
+ 'name': 'PERM00534',
+ 'owner': 'Administrator',
+ 'parent': 'SMS Control',
+ 'parentfield': 'permissions',
+ 'parenttype': 'DocType',
+ 'permlevel': 0,
+ 'read': 1,
+ 'role': 'Administrator',
+ 'submit': None,
+ 'write': 1
+ },
+ {
+ 'amend': None,
+ 'cancel': None,
+ 'create': None,
+ 'creation': '2010-08-08 17:09:24',
+ 'docstatus': 0,
+ 'doctype': 'DocPerm',
+ 'execute': None,
+ 'idx': 2,
+ 'match': None,
+ 'modified': '2011-04-08 16:53:02',
+ 'modified_by': 'Administrator',
+ 'name': 'PERM00535',
+ 'owner': 'Administrator',
+ 'parent': 'SMS Control',
+ 'parentfield': 'permissions',
+ 'parenttype': 'DocType',
+ 'permlevel': 1,
+ 'read': 1,
+ 'role': 'Administrator',
+ 'submit': None,
+ 'write': None
+ }
+]
\ No newline at end of file
diff --git a/tools/doctype/sms_log/__init__.py b/tools/doctype/sms_log/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tools/doctype/sms_log/__init__.py
diff --git a/tools/doctype/sms_log/sms_log.txt b/tools/doctype/sms_log/sms_log.txt
new file mode 100644
index 0000000..d53835b
--- /dev/null
+++ b/tools/doctype/sms_log/sms_log.txt
@@ -0,0 +1 @@
+[{'section_style': 'Simple', 'is_transaction_doc': None, 'creation': '2011-01-11 12:28:39', 'search_fields': None, 'module': 'Tools', 'doctype': 'DocType', 'change_log': None, 'print_outline': None, 'owner': 'Administrator', 'in_dialog': None, 'in_create': None, 'read_only': None, 'allow_email': None, 'dt_template': None, 'hide_heading': None, 'issingle': None, 'allow_rename': None, 'smallicon': None, 'allow_attach': None, 'show_in_menu': 0, 'max_attachments': None, 'version': 4, 'menu_index': None, 'docstatus': 0, 'allow_copy': None, 'istable': None, 'description': None, 'parent': None, 'server_code': None, 'allow_trash': None, 'allow_print': None, 'autoname': 'SMSLOG/.########', 'client_script_core': None, 'client_string': None, 'use_template': None, 'modified_by': 'Administrator', 'document_type': None, 'name': 'SMS Log', 'idx': None, 'hide_toolbar': None, 'colour': 'White:FFF', 'client_script': None, 'modified': '2011-01-11 12:51:46', 'server_code_error': None, 'name_case': None, 'parenttype': None, 'read_only_onload': None, 'server_code_core': None, 'server_code_compiled': None, 'parent_node': None, 'parentfield': None}, {'cancel': None, 'amend': None, 'execute': None, 'modified_by': 'Administrator', 'name': 'PERM00792', 'parent': 'SMS Log', 'read': 1, 'create': 0, 'creation': '2011-01-11 12:28:58', 'modified': '2011-01-11 12:51:46', 'submit': None, 'doctype': 'DocPerm', 'write': 0, 'idx': 1, 'parenttype': 'DocType', 'role': 'System Manager', 'owner': 'Administrator', 'docstatus': 0, 'permlevel': 0, 'match': None, 'parentfield': 'permissions'}, {'no_copy': None, 'oldfieldtype': None, 'creation': '2011-01-11 12:28:40', 'doctype': 'DocField', 'oldfieldname': None, 'owner': 'Administrator', 'reqd': None, 'in_filter': None, 'print_hide': None, 'modified_by': 'Administrator', 'label': None, 'width': '50%', 'trigger': None, 'depends_on': None, 'docstatus': 0, 'hidden': None, 'permlevel': 0, 'description': None, 'parent': 'SMS Log', 'search_index': None, 'allow_on_submit': None, 'icon': None, 'name': 'FL04405', 'idx': 1, 'default': None, 'colour': None, 'modified': '2011-01-11 12:51:46', 'parenttype': 'DocType', 'fieldname': None, 'fieldtype': 'Column Break', 'options': None, 'report_hide': None, 'parentfield': 'fields'}, {'no_copy': None, 'oldfieldtype': None, 'creation': '2011-01-11 12:28:40', 'doctype': 'DocField', 'oldfieldname': None, 'owner': 'Administrator', 'reqd': None, 'in_filter': None, 'print_hide': None, 'modified_by': 'Administrator', 'label': 'Sender Name', 'width': None, 'trigger': None, 'depends_on': None, 'docstatus': 0, 'hidden': None, 'permlevel': 0, 'description': None, 'parent': 'SMS Log', 'search_index': None, 'allow_on_submit': None, 'icon': None, 'name': 'FL04399', 'idx': 2, 'default': None, 'colour': None, 'modified': '2011-01-11 12:51:46', 'parenttype': 'DocType', 'fieldname': 'sender_name', 'fieldtype': 'Data', 'options': None, 'report_hide': None, 'parentfield': 'fields'}, {'no_copy': None, 'oldfieldtype': None, 'creation': '2011-01-11 12:28:40', 'doctype': 'DocField', 'oldfieldname': None, 'owner': 'Administrator', 'reqd': None, 'in_filter': None, 'print_hide': None, 'modified_by': 'Administrator', 'label': 'Sent On', 'width': None, 'trigger': None, 'depends_on': None, 'docstatus': 0, 'hidden': None, 'permlevel': 0, 'description': None, 'parent': 'SMS Log', 'search_index': None, 'allow_on_submit': None, 'icon': None, 'name': 'FL04400', 'idx': 3, 'default': None, 'colour': None, 'modified': '2011-01-11 12:51:46', 'parenttype': 'DocType', 'fieldname': 'sent_on', 'fieldtype': 'Date', 'options': None, 'report_hide': None, 'parentfield': 'fields'}, {'no_copy': None, 'oldfieldtype': None, 'creation': '2011-01-11 12:28:40', 'doctype': 'DocField', 'oldfieldname': None, 'owner': 'Administrator', 'reqd': None, 'in_filter': None, 'print_hide': None, 'modified_by': 'Administrator', 'label': 'Receiver List', 'width': None, 'trigger': None, 'depends_on': None, 'docstatus': 0, 'hidden': None, 'permlevel': 0, 'description': None, 'parent': 'SMS Log', 'search_index': None, 'allow_on_submit': None, 'icon': None, 'name': 'FL04401', 'idx': 4, 'default': None, 'colour': None, 'modified': '2011-01-11 12:51:46', 'parenttype': 'DocType', 'fieldname': 'receiver_list', 'fieldtype': 'Small Text', 'options': None, 'report_hide': None, 'parentfield': 'fields'}, {'no_copy': None, 'oldfieldtype': None, 'creation': '2011-01-11 12:28:40', 'doctype': 'DocField', 'oldfieldname': None, 'owner': 'Administrator', 'reqd': None, 'in_filter': None, 'print_hide': None, 'modified_by': 'Administrator', 'label': None, 'width': '50%', 'trigger': None, 'depends_on': None, 'docstatus': 0, 'hidden': None, 'permlevel': 0, 'description': None, 'parent': 'SMS Log', 'search_index': None, 'allow_on_submit': None, 'icon': None, 'name': 'FL04406', 'idx': 5, 'default': None, 'colour': None, 'modified': '2011-01-11 12:51:46', 'parenttype': 'DocType', 'fieldname': None, 'fieldtype': 'Column Break', 'options': None, 'report_hide': None, 'parentfield': 'fields'}, {'no_copy': None, 'oldfieldtype': None, 'creation': '2011-01-11 12:28:40', 'doctype': 'DocField', 'oldfieldname': None, 'owner': 'Administrator', 'reqd': None, 'in_filter': None, 'print_hide': None, 'modified_by': 'Administrator', 'label': 'No of Requested SMS', 'width': None, 'trigger': None, 'depends_on': None, 'docstatus': 0, 'hidden': None, 'permlevel': 0, 'description': None, 'parent': 'SMS Log', 'search_index': None, 'allow_on_submit': None, 'icon': None, 'name': 'FL04403', 'idx': 6, 'default': None, 'colour': None, 'modified': '2011-01-11 12:51:46', 'parenttype': 'DocType', 'fieldname': 'no_of_requested_sms', 'fieldtype': 'Int', 'options': None, 'report_hide': None, 'parentfield': 'fields'}, {'no_copy': None, 'oldfieldtype': None, 'creation': '2011-01-11 12:28:40', 'doctype': 'DocField', 'oldfieldname': None, 'owner': 'Administrator', 'reqd': None, 'in_filter': None, 'print_hide': None, 'modified_by': 'Administrator', 'label': 'No of Sent SMS', 'width': None, 'trigger': None, 'depends_on': None, 'docstatus': 0, 'hidden': None, 'permlevel': 0, 'description': None, 'parent': 'SMS Log', 'search_index': None, 'allow_on_submit': None, 'icon': None, 'name': 'FL04404', 'idx': 7, 'default': None, 'colour': None, 'modified': '2011-01-11 12:51:46', 'parenttype': 'DocType', 'fieldname': 'no_of_sent_sms', 'fieldtype': 'Int', 'options': None, 'report_hide': None, 'parentfield': 'fields'}, {'no_copy': None, 'oldfieldtype': None, 'creation': '2011-01-11 12:28:40', 'doctype': 'DocField', 'oldfieldname': None, 'owner': 'Administrator', 'reqd': None, 'in_filter': None, 'print_hide': None, 'modified_by': 'Administrator', 'label': 'Message', 'width': None, 'trigger': None, 'depends_on': None, 'docstatus': 0, 'hidden': None, 'permlevel': 0, 'description': None, 'parent': 'SMS Log', 'search_index': None, 'allow_on_submit': None, 'icon': None, 'name': 'FL04402', 'idx': 8, 'default': None, 'colour': None, 'modified': '2011-01-11 12:51:46', 'parenttype': 'DocType', 'fieldname': 'message', 'fieldtype': 'Small Text', 'options': None, 'report_hide': None, 'parentfield': 'fields'}]
\ No newline at end of file
diff --git a/tools/doctype/todo_item/__init__.py b/tools/doctype/todo_item/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tools/doctype/todo_item/__init__.py
diff --git a/tools/doctype/todo_item/todo_item.txt b/tools/doctype/todo_item/todo_item.txt
new file mode 100644
index 0000000..d3d014c
--- /dev/null
+++ b/tools/doctype/todo_item/todo_item.txt
@@ -0,0 +1 @@
+[{'section_style': 'Simple', 'is_transaction_doc': None, 'creation': '2009-03-12 12:01:55', 'search_fields': None, 'module': 'Tools', 'doctype': 'DocType', 'change_log': None, 'print_outline': '', 'owner': 'Administrator', 'in_dialog': None, 'in_create': 1, 'read_only': 1, 'allow_email': None, 'dt_template': None, 'hide_heading': None, 'issingle': None, 'allow_rename': None, 'smallicon': '', 'allow_attach': None, 'show_in_menu': 0, 'max_attachments': None, 'version': 9, 'menu_index': None, 'docstatus': 0, 'allow_copy': None, 'istable': None, 'description': None, 'parent': None, 'server_code': '', 'allow_trash': None, 'allow_print': None, 'autoname': 'TDI.########', 'client_script_core': None, 'client_string': None, 'use_template': None, 'modified_by': 'Administrator', 'document_type': None, 'name': 'ToDo Item', 'idx': None, 'hide_toolbar': None, 'colour': 'White:FFF', 'client_script': '', 'modified': '2010-09-20 14:06:57', 'server_code_error': ' ', 'name_case': '', 'parenttype': None, 'read_only_onload': None, 'server_code_core': '', 'server_code_compiled': None, 'parent_node': None, 'parentfield': None}, {'cancel': None, 'amend': None, 'execute': None, 'modified_by': 'Administrator', 'name': 'PERM00019', 'parent': 'ToDo Item', 'read': 1, 'create': 1, 'creation': '2009-03-12 12:01:57', 'modified': '2010-05-06 18:12:29', 'submit': None, 'doctype': 'DocPerm', 'write': 1, 'idx': 1, 'parenttype': 'DocType', 'role': 'All', 'owner': 'Administrator', 'docstatus': 0, 'permlevel': None, 'match': None, 'parentfield': 'permissions'}, {'no_copy': None, 'oldfieldtype': 'Text', 'creation': '2009-03-12 12:01:57', 'doctype': 'DocField', 'oldfieldname': 'description', 'owner': 'Administrator', 'reqd': None, 'in_filter': None, 'print_hide': None, 'modified_by': 'Administrator', 'label': 'Description', 'width': None, 'trigger': None, 'depends_on': None, 'docstatus': 0, 'hidden': None, 'permlevel': 0, 'description': None, 'parent': 'ToDo Item', 'search_index': None, 'allow_on_submit': None, 'icon': None, 'name': 'FL00227', 'idx': 1, 'default': None, 'colour': None, 'modified': '2010-05-06 18:12:29', 'parenttype': 'DocType', 'fieldname': 'description', 'fieldtype': 'Text', 'options': None, 'report_hide': None, 'parentfield': 'fields'}, {'no_copy': None, 'oldfieldtype': 'Date', 'creation': '2009-03-12 12:01:57', 'doctype': 'DocField', 'oldfieldname': 'date', 'owner': 'Administrator', 'reqd': 0, 'in_filter': None, 'print_hide': None, 'modified_by': 'Administrator', 'label': 'Date', 'width': None, 'trigger': None, 'depends_on': None, 'docstatus': 0, 'hidden': None, 'permlevel': 0, 'description': None, 'parent': 'ToDo Item', 'search_index': None, 'allow_on_submit': None, 'icon': None, 'name': 'FL00228', 'idx': 2, 'default': None, 'colour': None, 'modified': '2010-05-06 18:12:29', 'parenttype': 'DocType', 'fieldname': 'date', 'fieldtype': 'Date', 'options': None, 'report_hide': None, 'parentfield': 'fields'}, {'no_copy': None, 'oldfieldtype': 'Data', 'creation': '2009-03-12 12:01:57', 'doctype': 'DocField', 'oldfieldname': 'priority', 'owner': 'Administrator', 'reqd': 0, 'in_filter': None, 'print_hide': None, 'modified_by': 'Administrator', 'label': 'Priority', 'width': None, 'trigger': None, 'depends_on': None, 'docstatus': 0, 'hidden': None, 'permlevel': 0, 'description': None, 'parent': 'ToDo Item', 'search_index': None, 'allow_on_submit': None, 'icon': None, 'name': 'FL00229', 'idx': 3, 'default': None, 'colour': None, 'modified': '2010-05-06 18:12:29', 'parenttype': 'DocType', 'fieldname': 'priority', 'fieldtype': 'Data', 'options': None, 'report_hide': None, 'parentfield': 'fields'}, {'no_copy': None, 'oldfieldtype': 'Data', 'creation': '2009-03-12 12:01:57', 'doctype': 'DocField', 'oldfieldname': 'reference_type', 'owner': 'Administrator', 'reqd': None, 'in_filter': None, 'print_hide': None, 'modified_by': 'Administrator', 'label': 'Reference Type', 'width': None, 'trigger': None, 'depends_on': None, 'docstatus': 0, 'hidden': None, 'permlevel': 0, 'description': None, 'parent': 'ToDo Item', 'search_index': None, 'allow_on_submit': None, 'icon': None, 'name': 'FL00230', 'idx': 4, 'default': None, 'colour': None, 'modified': '2010-05-06 18:12:29', 'parenttype': 'DocType', 'fieldname': 'reference_type', 'fieldtype': 'Data', 'options': None, 'report_hide': None, 'parentfield': 'fields'}, {'no_copy': None, 'oldfieldtype': 'Data', 'creation': '2009-03-12 12:01:57', 'doctype': 'DocField', 'oldfieldname': 'reference_name', 'owner': 'Administrator', 'reqd': None, 'in_filter': None, 'print_hide': None, 'modified_by': 'Administrator', 'label': 'Reference Name', 'width': None, 'trigger': None, 'depends_on': None, 'docstatus': 0, 'hidden': None, 'permlevel': 0, 'description': None, 'parent': 'ToDo Item', 'search_index': None, 'allow_on_submit': None, 'icon': None, 'name': 'FL00231', 'idx': 5, 'default': None, 'colour': None, 'modified': '2010-05-06 18:12:29', 'parenttype': 'DocType', 'fieldname': 'reference_name', 'fieldtype': 'Data', 'options': None, 'report_hide': None, 'parentfield': 'fields'}, {'no_copy': None, 'oldfieldtype': 'Check', 'creation': '2009-03-12 12:01:57', 'doctype': 'DocField', 'oldfieldname': 'checked', 'owner': 'Administrator', 'reqd': 0, 'in_filter': None, 'print_hide': None, 'modified_by': 'Administrator', 'label': 'Checked', 'width': None, 'trigger': None, 'depends_on': None, 'docstatus': 0, 'hidden': None, 'permlevel': 0, 'description': None, 'parent': 'ToDo Item', 'search_index': None, 'allow_on_submit': None, 'icon': None, 'name': 'FL00232', 'idx': 6, 'default': None, 'colour': None, 'modified': '2010-05-06 18:12:29', 'parenttype': 'DocType', 'fieldname': 'checked', 'fieldtype': 'Check', 'options': None, 'report_hide': None, 'parentfield': 'fields'}, {'no_copy': None, 'oldfieldtype': 'Link', 'creation': '2009-03-12 12:01:57', 'doctype': 'DocField', 'oldfieldname': 'role', 'owner': 'Administrator', 'reqd': None, 'in_filter': None, 'print_hide': None, 'modified_by': 'Administrator', 'label': 'Role', 'width': None, 'trigger': None, 'depends_on': None, 'docstatus': 0, 'hidden': None, 'permlevel': 0, 'description': None, 'parent': 'ToDo Item', 'search_index': None, 'allow_on_submit': None, 'icon': None, 'name': 'FL00233', 'idx': 7, 'default': None, 'colour': None, 'modified': '2010-05-06 18:12:29', 'parenttype': 'DocType', 'fieldname': 'role', 'fieldtype': 'Link', 'options': 'Role', 'report_hide': None, 'parentfield': 'fields'}]
\ No newline at end of file
diff --git a/tools/doctype/trash_control/__init__.py b/tools/doctype/trash_control/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tools/doctype/trash_control/__init__.py
diff --git a/tools/doctype/trash_control/trash_control.py b/tools/doctype/trash_control/trash_control.py
new file mode 100644
index 0000000..644a278
--- /dev/null
+++ b/tools/doctype/trash_control/trash_control.py
@@ -0,0 +1,59 @@
+# Please edit this list and import only required elements
+import webnotes
+
+from webnotes.utils import add_days, add_months, add_years, cint, cstr, date_diff, default_fields, flt, fmt_money, formatdate, generate_hash, getTraceback, get_defaults, get_first_day, get_last_day, getdate, has_common, month_name, now, nowdate, replace_newlines, sendmail, set_default, str_esc_quote, user_format, validate_email_add
+from webnotes.model import db_exists
+from webnotes.model.doc import Document, addchild, removechild, getchildren, make_autoname, SuperDocType
+from webnotes.model.doclist import getlist, copy_doclist
+from webnotes.model.code import get_obj, get_server_obj, run_server_obj, updatedb, check_syntax
+from webnotes import session, form, is_testing, msgprint, errprint
+
+set = webnotes.conn.set
+sql = webnotes.conn.sql
+get_value = webnotes.conn.get_value
+in_transaction = webnotes.conn.in_transaction
+convert_to_lists = webnotes.conn.convert_to_lists
+
+# -----------------------------------------------------------------------------------------
+
+
+class DocType:
+ def __init__(self, d, dl):
+ self.doc, self.doclist = d, dl
+
+
+ # Get Masters
+ # -----------
+ def get_masters(self):
+ mlist = []
+ res = sql("select distinct t1.name from tabDocType t1, tabDocPerm t2 where ifnull(t1.allow_trash, 0) = 1 and (ifnull(t2.write, 0) = 1 or ifnull(t2.create, 0) = 1) and t2.role in %s and t2.parent = t1.name and t1.module not in ('DocType','Application Internal','Recycle Bin','Development','Testing','Testing System','Test') ORDER BY t1.name" % cstr(tuple(webnotes.user.get_roles())))
+ for r in res:
+ mlist.append(r[0])
+ return mlist
+
+
+ # Get Trash Records
+ # -----------------
+ def get_trash_records(self, mast_name):
+ mlist = []
+ rec_dict = {}
+ if mast_name == 'All':
+ mlist = self.get_masters()
+ else:
+ mlist.append(mast_name)
+ for i in mlist:
+ rec = [r[0] for r in sql("select name from `tab%s` where docstatus = 2" % i)]
+ if rec:
+ rec_dict[i] = rec
+ return rec_dict
+
+
+ # Restore Records
+ # ---------------
+ def restore_records(self, arg):
+ arg = eval(arg)
+ for k in arg:
+ for r in arg[k]:
+ sql("update `tab%s` set docstatus = 0, modified = '%s', trash_reason = '' where name = '%s'" % (k, now(), r))
+ dt_obj = get_obj(k,r)
+ if hasattr(dt_obj, 'on_restore'): dt_obj.on_restore()
\ No newline at end of file
diff --git a/tools/doctype/trash_control/trash_control.txt b/tools/doctype/trash_control/trash_control.txt
new file mode 100644
index 0000000..b38d5a2
--- /dev/null
+++ b/tools/doctype/trash_control/trash_control.txt
@@ -0,0 +1 @@
+[{'section_style': 'Simple', 'is_transaction_doc': None, 'creation': '2010-04-19 09:59:18', 'search_fields': None, 'module': 'Tools', 'doctype': 'DocType', 'change_log': None, 'print_outline': '', 'owner': 'Administrator', 'in_dialog': None, 'in_create': 1, 'read_only': 1, 'allow_email': None, 'dt_template': None, 'hide_heading': None, 'issingle': 1, 'allow_rename': None, 'smallicon': '', 'allow_attach': None, 'show_in_menu': None, 'max_attachments': None, 'version': 37, 'menu_index': None, 'docstatus': 0, 'allow_copy': None, 'istable': None, 'description': None, 'parent': None, 'server_code': None, 'allow_trash': None, 'allow_print': None, 'autoname': None, 'client_script_core': None, 'client_string': None, 'use_template': None, 'modified_by': 'saumil@webnotestech.com', 'document_type': '', 'name': 'Trash Control', 'idx': None, 'hide_toolbar': None, 'colour': 'White:FFF', 'client_script': None, 'modified': '2010-10-13 16:35:49', 'server_code_error': ' ', 'name_case': '', 'parenttype': None, 'read_only_onload': None, 'server_code_core': None, 'server_code_compiled': None, 'parent_node': None, 'parentfield': None}]
\ No newline at end of file
diff --git a/tools/doctype/tweet/__init__.py b/tools/doctype/tweet/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tools/doctype/tweet/__init__.py
diff --git a/tools/doctype/tweet/tweet.txt b/tools/doctype/tweet/tweet.txt
new file mode 100644
index 0000000..5478912
--- /dev/null
+++ b/tools/doctype/tweet/tweet.txt
@@ -0,0 +1 @@
+[{'section_style': 'Simple', 'is_transaction_doc': None, 'creation': '2009-05-13 12:23:54', 'search_fields': None, 'module': 'Tools', 'doctype': 'DocType', 'change_log': None, 'print_outline': '', 'owner': 'Administrator', 'in_dialog': None, 'in_create': None, 'read_only': None, 'allow_email': None, 'dt_template': None, 'hide_heading': None, 'issingle': None, 'allow_rename': None, 'smallicon': '', 'allow_attach': None, 'show_in_menu': 0, 'max_attachments': None, 'version': 6, 'menu_index': None, 'docstatus': 0, 'allow_copy': None, 'istable': None, 'description': None, 'parent': None, 'server_code': None, 'allow_trash': None, 'allow_print': None, 'autoname': 'TW.######', 'client_script_core': '', 'client_string': None, 'use_template': None, 'modified_by': 'Administrator', 'document_type': None, 'name': 'Tweet', 'idx': None, 'hide_toolbar': None, 'colour': 'White:FFF', 'client_script': None, 'modified': '2010-09-17 12:48:20', 'server_code_error': None, 'name_case': '', 'parenttype': None, 'read_only_onload': None, 'server_code_core': '', 'server_code_compiled': None, 'parent_node': None, 'parentfield': None}, {'cancel': None, 'amend': None, 'execute': None, 'modified_by': 'Administrator', 'name': 'PERM00289', 'parent': 'Tweet', 'read': 1, 'create': None, 'creation': '2009-05-13 12:23:54', 'modified': '2010-03-31 10:23:27', 'submit': None, 'doctype': 'DocPerm', 'write': None, 'idx': 1, 'parenttype': 'DocType', 'role': 'Administrator', 'owner': 'Administrator', 'docstatus': 0, 'permlevel': 0, 'match': None, 'parentfield': 'permissions'}, {'no_copy': None, 'oldfieldtype': 'Link', 'creation': '2009-05-13 12:23:54', 'doctype': 'DocField', 'oldfieldname': 'by', 'owner': 'Administrator', 'reqd': None, 'in_filter': 1, 'print_hide': None, 'modified_by': 'Administrator', 'label': 'By', 'width': None, 'trigger': None, 'depends_on': None, 'docstatus': 0, 'hidden': None, 'permlevel': 0, 'description': None, 'parent': 'Tweet', 'search_index': 1, 'allow_on_submit': None, 'icon': None, 'name': 'FL02041', 'idx': 1, 'default': None, 'colour': None, 'modified': '2010-03-31 10:23:27', 'parenttype': 'DocType', 'fieldname': 'by', 'fieldtype': 'Link', 'options': 'Profile', 'report_hide': None, 'parentfield': 'fields'}, {'no_copy': None, 'oldfieldtype': 'Text', 'creation': '2009-05-13 12:23:54', 'doctype': 'DocField', 'oldfieldname': 'comment', 'owner': 'Administrator', 'reqd': None, 'in_filter': None, 'print_hide': None, 'modified_by': 'Administrator', 'label': 'Comment', 'width': None, 'trigger': None, 'depends_on': None, 'docstatus': 0, 'hidden': None, 'permlevel': 0, 'description': None, 'parent': 'Tweet', 'search_index': None, 'allow_on_submit': None, 'icon': None, 'name': 'FL02042', 'idx': 2, 'default': None, 'colour': None, 'modified': '2010-03-31 10:23:27', 'parenttype': 'DocType', 'fieldname': 'comment', 'fieldtype': 'Text', 'options': None, 'report_hide': None, 'parentfield': 'fields'}, {'no_copy': None, 'oldfieldtype': 'Data', 'creation': '2009-08-26 01:31:48', 'doctype': 'DocField', 'oldfieldname': 'tag', 'owner': 'Administrator', 'reqd': None, 'in_filter': 1, 'print_hide': None, 'modified_by': 'Administrator', 'label': 'Tag', 'width': None, 'trigger': None, 'depends_on': None, 'docstatus': 0, 'hidden': None, 'permlevel': 0, 'description': None, 'parent': 'Tweet', 'search_index': 1, 'allow_on_submit': None, 'icon': None, 'name': 'FL02712', 'idx': 3, 'default': None, 'colour': None, 'modified': '2010-03-31 10:23:27', 'parenttype': 'DocType', 'fieldname': 'tag', 'fieldtype': 'Data', 'options': None, 'report_hide': None, 'parentfield': 'fields'}]
\ No newline at end of file
diff --git a/tools/doctype/while_you_were_out/__init__.py b/tools/doctype/while_you_were_out/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tools/doctype/while_you_were_out/__init__.py
diff --git a/tools/doctype/while_you_were_out/while_you_were_out.txt b/tools/doctype/while_you_were_out/while_you_were_out.txt
new file mode 100644
index 0000000..7dc7ccb
--- /dev/null
+++ b/tools/doctype/while_you_were_out/while_you_were_out.txt
@@ -0,0 +1 @@
+[{'section_style': 'Simple', 'is_transaction_doc': None, 'creation': '2010-01-08 17:28:22', 'search_fields': None, 'module': 'Tools', 'doctype': 'DocType', 'change_log': None, 'print_outline': '', 'owner': 'dhanalekshmi@webnotestech.com', 'in_dialog': None, 'in_create': None, 'read_only': None, 'allow_email': None, 'dt_template': None, 'hide_heading': None, 'issingle': None, 'allow_rename': None, 'smallicon': None, 'allow_attach': None, 'show_in_menu': 0, 'max_attachments': None, 'version': 12, 'menu_index': None, 'docstatus': 0, 'allow_copy': None, 'istable': None, 'description': None, 'parent': None, 'server_code': None, 'allow_trash': None, 'allow_print': None, 'autoname': 'WYWR/.####', 'client_script_core': None, 'client_string': None, 'use_template': None, 'modified_by': 'Administrator', 'document_type': None, 'name': 'While You Were Out', 'idx': None, 'hide_toolbar': None, 'colour': 'White:FFF', 'client_script': None, 'modified': '2010-09-20 14:06:57', 'server_code_error': ' ', 'name_case': '', 'parenttype': None, 'read_only_onload': None, 'server_code_core': None, 'server_code_compiled': None, 'parent_node': None, 'parentfield': None}, {'cancel': None, 'amend': None, 'execute': None, 'modified_by': 'Administrator', 'name': 'PERM00569', 'parent': 'While You Were Out', 'read': 1, 'create': 1, 'creation': '2010-01-08 17:28:22', 'modified': '2010-03-31 09:47:12', 'submit': None, 'doctype': 'DocPerm', 'write': 1, 'idx': 1, 'parenttype': 'DocType', 'role': 'Administrator', 'owner': 'dhanalekshmi@webnotestech.com', 'docstatus': 0, 'permlevel': 0, 'match': None, 'parentfield': 'permissions'}, {'no_copy': None, 'oldfieldtype': 'Section Break', 'creation': '2010-01-08 17:28:22', 'doctype': 'DocField', 'oldfieldname': None, 'owner': 'dhanalekshmi@webnotestech.com', 'reqd': None, 'in_filter': None, 'print_hide': None, 'modified_by': 'Administrator', 'label': 'While You Were Out', 'width': None, 'trigger': None, 'depends_on': None, 'docstatus': 0, 'hidden': None, 'permlevel': 0, 'description': None, 'parent': 'While You Were Out', 'search_index': None, 'allow_on_submit': None, 'icon': None, 'name': 'FL03551', 'idx': 1, 'default': None, 'colour': None, 'modified': '2010-03-31 09:47:12', 'parenttype': 'DocType', 'fieldname': None, 'fieldtype': 'Section Break', 'options': None, 'report_hide': None, 'parentfield': 'fields'}, {'no_copy': None, 'oldfieldtype': 'Data', 'creation': '2010-01-08 17:28:22', 'doctype': 'DocField', 'oldfieldname': 'from_user', 'owner': 'dhanalekshmi@webnotestech.com', 'reqd': None, 'in_filter': 1, 'print_hide': None, 'modified_by': 'Administrator', 'label': 'From', 'width': None, 'trigger': None, 'depends_on': None, 'docstatus': 0, 'hidden': None, 'permlevel': 0, 'description': None, 'parent': 'While You Were Out', 'search_index': None, 'allow_on_submit': None, 'icon': None, 'name': 'FL03552', 'idx': 2, 'default': '__user', 'colour': None, 'modified': '2010-03-31 09:47:12', 'parenttype': 'DocType', 'fieldname': 'from_user', 'fieldtype': 'Data', 'options': None, 'report_hide': None, 'parentfield': 'fields'}, {'no_copy': None, 'oldfieldtype': 'Link', 'creation': '2010-01-08 17:28:22', 'doctype': 'DocField', 'oldfieldname': 'to_user', 'owner': 'dhanalekshmi@webnotestech.com', 'reqd': None, 'in_filter': 1, 'print_hide': None, 'modified_by': 'Administrator', 'label': 'To', 'width': None, 'trigger': None, 'depends_on': None, 'docstatus': 0, 'hidden': None, 'permlevel': 0, 'description': None, 'parent': 'While You Were Out', 'search_index': None, 'allow_on_submit': None, 'icon': None, 'name': 'FL03553', 'idx': 3, 'default': None, 'colour': None, 'modified': '2010-03-31 09:47:12', 'parenttype': 'DocType', 'fieldname': 'to_user', 'fieldtype': 'Link', 'options': 'Profile', 'report_hide': None, 'parentfield': 'fields'}, {'no_copy': None, 'oldfieldtype': 'Text', 'creation': '2010-01-08 17:28:22', 'doctype': 'DocField', 'oldfieldname': 'message', 'owner': 'dhanalekshmi@webnotestech.com', 'reqd': None, 'in_filter': 1, 'print_hide': None, 'modified_by': 'Administrator', 'label': 'Message', 'width': None, 'trigger': None, 'depends_on': None, 'docstatus': 0, 'hidden': None, 'permlevel': 0, 'description': None, 'parent': 'While You Were Out', 'search_index': None, 'allow_on_submit': None, 'icon': None, 'name': 'FL03554', 'idx': 4, 'default': None, 'colour': None, 'modified': '2010-03-31 09:47:12', 'parenttype': 'DocType', 'fieldname': 'message', 'fieldtype': 'Text', 'options': None, 'report_hide': None, 'parentfield': 'fields'}]
\ No newline at end of file
diff --git a/tools/doctype/wiki_control/__init__.py b/tools/doctype/wiki_control/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tools/doctype/wiki_control/__init__.py
diff --git a/tools/doctype/wiki_control/wiki_control.py b/tools/doctype/wiki_control/wiki_control.py
new file mode 100644
index 0000000..254ca98
--- /dev/null
+++ b/tools/doctype/wiki_control/wiki_control.py
@@ -0,0 +1,32 @@
+# Please edit this list and import only required elements
+import webnotes
+
+from webnotes.utils import add_days, add_months, add_years, cint, cstr, date_diff, default_fields, flt, fmt_money, formatdate, generate_hash, getTraceback, get_defaults, get_first_day, get_last_day, getdate, has_common, month_name, now, nowdate, replace_newlines, sendmail, set_default, str_esc_quote, user_format, validate_email_add
+from webnotes.model import db_exists
+from webnotes.model.doc import Document, addchild, removechild, getchildren, make_autoname, SuperDocType
+from webnotes.model.doclist import getlist, copy_doclist
+from webnotes.model.code import get_obj, get_server_obj, run_server_obj, updatedb, check_syntax
+from webnotes import session, form, is_testing, msgprint, errprint
+
+set = webnotes.conn.set
+sql = webnotes.conn.sql
+get_value = webnotes.conn.get_value
+in_transaction = webnotes.conn.in_transaction
+convert_to_lists = webnotes.conn.convert_to_lists
+
+# -----------------------------------------------------------------------------------------
+
+
+class DocType:
+ def __init__(self,d,dl):
+ self.doc = d
+ self.doclist = dl
+
+ def get_wiki_detail(self,arg):
+ arg = eval(arg)
+ ret = {}
+ latest_revision = sql("select max(revision) from `tabWiki History` where reference=%s", arg['dn'])[0][0]
+
+ ret['detail'] = convert_to_lists(sql("select revision, modified_by,creation from `tabWiki History` where reference=%s and revision=%s", (arg['dn'],latest_revision)))
+ ret['contributors'] = convert_to_lists(sql("select distinct modified_by from `tabWiki History` where reference=%s", arg['dn']))
+ return ret
\ No newline at end of file
diff --git a/tools/doctype/wiki_control/wiki_control.txt b/tools/doctype/wiki_control/wiki_control.txt
new file mode 100644
index 0000000..70f6474
--- /dev/null
+++ b/tools/doctype/wiki_control/wiki_control.txt
@@ -0,0 +1 @@
+[{'section_style': 'Simple', 'is_transaction_doc': None, 'creation': '2009-12-08 18:08:48', 'search_fields': None, 'module': 'Tools', 'doctype': 'DocType', 'change_log': None, 'print_outline': '', 'owner': 'Administrator', 'in_dialog': None, 'in_create': None, 'read_only': None, 'allow_email': None, 'dt_template': None, 'hide_heading': None, 'issingle': 1, 'allow_rename': None, 'smallicon': None, 'allow_attach': None, 'show_in_menu': 0, 'max_attachments': None, 'version': 2, 'menu_index': None, 'docstatus': 0, 'allow_copy': None, 'istable': None, 'description': None, 'parent': None, 'server_code': None, 'allow_trash': None, 'allow_print': None, 'autoname': None, 'client_script_core': None, 'client_string': None, 'use_template': None, 'modified_by': 'Administrator', 'document_type': None, 'name': 'Wiki Control', 'idx': None, 'hide_toolbar': None, 'colour': 'White:FFF', 'client_script': None, 'modified': '2010-09-20 14:06:57', 'server_code_error': None, 'name_case': '', 'parenttype': None, 'read_only_onload': None, 'server_code_core': None, 'server_code_compiled': None, 'parent_node': None, 'parentfield': None}, {'cancel': None, 'amend': None, 'execute': None, 'modified_by': 'Administrator', 'name': 'PERM00528', 'parent': 'Wiki Control', 'read': None, 'create': None, 'creation': '2009-12-08 18:08:48', 'modified': '2009-12-09 16:57:54', 'submit': None, 'doctype': 'DocPerm', 'write': None, 'idx': 1, 'parenttype': 'DocType', 'role': 'Administrator', 'owner': 'Administrator', 'docstatus': 0, 'permlevel': 0, 'match': None, 'parentfield': 'permissions'}]
\ No newline at end of file
diff --git a/tools/doctype/wiki_history/__init__.py b/tools/doctype/wiki_history/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tools/doctype/wiki_history/__init__.py
diff --git a/tools/doctype/wiki_history/wiki_history.txt b/tools/doctype/wiki_history/wiki_history.txt
new file mode 100644
index 0000000..3bb1fab
--- /dev/null
+++ b/tools/doctype/wiki_history/wiki_history.txt
@@ -0,0 +1 @@
+[{'section_style': 'Simple', 'is_transaction_doc': None, 'creation': '2009-12-08 11:22:40', 'search_fields': None, 'module': 'Tools', 'doctype': 'DocType', 'change_log': None, 'print_outline': '', 'owner': 'Administrator', 'in_dialog': None, 'in_create': None, 'read_only': None, 'allow_email': None, 'dt_template': None, 'hide_heading': None, 'issingle': None, 'allow_rename': None, 'smallicon': None, 'allow_attach': None, 'show_in_menu': 0, 'max_attachments': None, 'version': 5, 'menu_index': None, 'docstatus': 0, 'allow_copy': None, 'istable': None, 'description': None, 'parent': None, 'server_code': None, 'allow_trash': None, 'allow_print': None, 'autoname': 'WH/.#####', 'client_script_core': None, 'client_string': None, 'use_template': None, 'modified_by': 'Administrator', 'document_type': None, 'name': 'Wiki History', 'idx': None, 'hide_toolbar': None, 'colour': 'White:FFF', 'client_script': None, 'modified': '2010-09-20 14:06:57', 'server_code_error': None, 'name_case': '', 'parenttype': None, 'read_only_onload': None, 'server_code_core': None, 'server_code_compiled': None, 'parent_node': None, 'parentfield': None}, {'cancel': None, 'amend': None, 'execute': None, 'modified_by': 'Administrator', 'name': 'PERM00527', 'parent': 'Wiki History', 'read': 1, 'create': 1, 'creation': '2009-12-08 11:22:40', 'modified': '2009-12-09 16:57:44', 'submit': None, 'doctype': 'DocPerm', 'write': 1, 'idx': 1, 'parenttype': 'DocType', 'role': 'Administrator', 'owner': 'Administrator', 'docstatus': 0, 'permlevel': 0, 'match': None, 'parentfield': 'permissions'}, {'no_copy': None, 'oldfieldtype': 'Data', 'creation': '2009-12-08 11:22:40', 'doctype': 'DocField', 'oldfieldname': 'reference', 'owner': 'Administrator', 'reqd': None, 'in_filter': None, 'print_hide': None, 'modified_by': 'Administrator', 'label': 'Reference', 'width': None, 'trigger': None, 'depends_on': None, 'docstatus': 0, 'hidden': None, 'permlevel': 0, 'description': None, 'parent': 'Wiki History', 'search_index': None, 'allow_on_submit': None, 'icon': None, 'name': 'FL03483', 'idx': 1, 'default': None, 'colour': None, 'modified': '2009-12-09 16:57:44', 'parenttype': 'DocType', 'fieldname': 'reference', 'fieldtype': 'Data', 'options': None, 'report_hide': None, 'parentfield': 'fields'}, {'no_copy': None, 'oldfieldtype': 'Data', 'creation': '2009-12-08 11:22:40', 'doctype': 'DocField', 'oldfieldname': 'version_no', 'owner': 'Administrator', 'reqd': None, 'in_filter': None, 'print_hide': 1, 'modified_by': 'Administrator', 'label': 'Version No', 'width': None, 'trigger': None, 'depends_on': None, 'docstatus': 0, 'hidden': 1, 'permlevel': 0, 'description': None, 'parent': 'Wiki History', 'search_index': None, 'allow_on_submit': None, 'icon': None, 'name': 'FL03484', 'idx': 2, 'default': None, 'colour': None, 'modified': '2009-12-09 16:57:44', 'parenttype': 'DocType', 'fieldname': 'version_no', 'fieldtype': 'Data', 'options': None, 'report_hide': None, 'parentfield': 'fields'}, {'no_copy': None, 'oldfieldtype': 'Int', 'creation': '2009-12-08 17:57:57', 'doctype': 'DocField', 'oldfieldname': 'revision', 'owner': 'Administrator', 'reqd': None, 'in_filter': None, 'print_hide': None, 'modified_by': 'Administrator', 'label': 'Revision', 'width': None, 'trigger': None, 'depends_on': None, 'docstatus': 0, 'hidden': None, 'permlevel': 0, 'description': None, 'parent': 'Wiki History', 'search_index': None, 'allow_on_submit': None, 'icon': None, 'name': 'FL03487', 'idx': 3, 'default': None, 'colour': None, 'modified': '2009-12-09 16:57:44', 'parenttype': 'DocType', 'fieldname': 'revision', 'fieldtype': 'Int', 'options': None, 'report_hide': None, 'parentfield': 'fields'}, {'no_copy': None, 'oldfieldtype': 'Text Editor', 'creation': '2009-12-08 11:22:40', 'doctype': 'DocField', 'oldfieldname': 'editor', 'owner': 'Administrator', 'reqd': None, 'in_filter': None, 'print_hide': None, 'modified_by': 'Administrator', 'label': 'Editor', 'width': None, 'trigger': None, 'depends_on': None, 'docstatus': 0, 'hidden': None, 'permlevel': 0, 'description': None, 'parent': 'Wiki History', 'search_index': None, 'allow_on_submit': None, 'icon': None, 'name': 'FL03485', 'idx': 4, 'default': None, 'colour': None, 'modified': '2009-12-09 16:57:44', 'parenttype': 'DocType', 'fieldname': 'editor', 'fieldtype': 'Text Editor', 'options': None, 'report_hide': None, 'parentfield': 'fields'}]
\ No newline at end of file
diff --git a/tools/doctype/wiki_page/__init__.py b/tools/doctype/wiki_page/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tools/doctype/wiki_page/__init__.py
diff --git a/tools/doctype/wiki_page/wiki_page.txt b/tools/doctype/wiki_page/wiki_page.txt
new file mode 100644
index 0000000..1a6bb4d
--- /dev/null
+++ b/tools/doctype/wiki_page/wiki_page.txt
@@ -0,0 +1 @@
+[{'section_style': 'Simple', 'is_transaction_doc': None, 'creation': '2009-12-04 10:56:29', 'search_fields': None, 'module': 'Tools', 'doctype': 'DocType', 'change_log': None, 'print_outline': '', 'owner': 'Administrator', 'in_dialog': None, 'in_create': None, 'read_only': None, 'allow_email': None, 'dt_template': None, 'hide_heading': 1, 'issingle': None, 'allow_rename': None, 'smallicon': None, 'allow_attach': None, 'show_in_menu': 0, 'max_attachments': None, 'version': 43, 'menu_index': None, 'docstatus': 0, 'allow_copy': None, 'istable': None, 'description': None, 'parent': None, 'server_code': 'class DocType:\n def __init__(self, d, dl):\n self.doc, self.doclist = d,dl\n\n # replace $image\n # ------------------\n def validate(self):\n import re\n p = re.compile(\'\\$page\\( (?P<name> [^)]*) \\)\', re.VERBOSE)\n i = re.compile(\'\\$image\\( (?P<name> [^)]*) \\)\', re.VERBOSE)\n if self.doc.editor:\n self.doc.editor = p.sub(self.replace_by_link, self.doc.editor)\n self.doc.editor = i.sub(self.replace_by_img, self.doc.editor)\n \n def replace_by_link(self, match):\n name = match.group(\'name\')\n \n # create wiki page if not created\n if not db_exists(\'Wiki Page\', name):\n w = Document(\'Wiki Page\')\n w.page_name = name\n w.save(1)\n \n return \'\'\'<a href="javascript:loaddoc(\'Wiki Page\',\'%s\')">%s</a>\'\'\' % (name, name)\n \n def replace_by_img(self, match):\n name = match.group(\'name\')\n return \'<img src="cgi-bin/getfile.cgi?ac=%s&name=%s">\' % (session[\'data\'][\'control_panel\'][\'account_id\'], name) \n \n def on_update(self):\n if not sql("select name from `tabWiki History` where reference=%s", self.doc.name):\n latest_revision = 0\n self.make_history(latest_revision)\n else:\n latest_revision = sql("select max(revision) from `tabWiki History` where reference=%s", self.doc.name)[0][0]\n if latest_revision:\n content = sql("select editor from `tabWiki History` where revision = %s and reference = %s", (latest_revision, self.doc.name))[0][0]\n \n if content == self.doc.editor:\n pass\n else:\n self.make_history(latest_revision)\n\n def make_history(self,revision):\n wh = Document(\'Wiki History\')\n wh.reference = self.doc.name\n wh.editor = self.doc.editor\n wh.revision = cint(revision) + 1\n wh.save(1)', 'allow_trash': None, 'allow_print': None, 'autoname': 'field:page_name', 'client_script_core': None, 'client_string': None, 'use_template': None, 'modified_by': 'Administrator', 'document_type': None, 'name': 'Wiki Page', 'idx': None, 'hide_toolbar': 1, 'colour': 'White:FFF', 'client_script': 'cur_frm.cscript.onload = function(doc,dt,dn) {\n pscript.cur_doc = doc; pscript.cur_dt = dt; pscript.cur_dn = dn;\n \n set_field_options(\'Page HTML\', doc.editor);\n set_field_options(\'Heading\', \'<h1>\'+doc.name+\'</h1>\');\n \n\n unhide_field(\'Page HTML\');\n unhide_field(\'Edit\');\n\n hide_field(\'editor\');\n hide_field(\'Done\');\n \n pscript.show_wiki_history(doc,dt,dn);\n}\n\ncur_frm.cscript.refresh = function() {\n \n}\n\ncur_frm.cscript.Edit = function(doc,dt,dn) {\n hide_field(\'Page HTML\');\n hide_field(\'Edit\');\n\n unhide_field(\'editor\');\n unhide_field(\'Done\');\n}\n\ncur_frm.cscript.Done = function(doc,dt,dn) {\n\n unhide_field(\'Page HTML\');\n unhide_field(\'Edit\');\n\n hide_field(\'editor\');\n hide_field(\'Done\');\n\n cur_frm.save(\'Save\', function() {\n set_field_options(\'Page HTML\', locals[\'Wiki Page\'][doc.name].editor);\n pscript.show_wiki_history(doc,dt,dn);\n });\n //\n}\n\n// Showing wiki detail\npscript.show_wiki_history = function(doc,dt,dn){\n /* $c(\'runserverobj\',args={\'method\':\'get_wiki_detail\',\'docs\':compress_doclist([doc])},\n function(r,rt){\n alert(\'in callback\');\n alert(r.message);\n detail = r.message.detail;\n contributors = r.message.contributors;\n \n var txt = \'<br>This is Revision - \' + detail[0][0] + \' of \' + dn +\'.\' + \'<br>Last modified by \' + detail[0][1] + \' on \' + dateutil.str_to_user(detail[0][2])\n + \'<br><br>Contributors : \' + contributors.join(\', \');\n set_field_options(\'History HTML\', txt);\n })*/\n \n var callback = function(r,rt){\n detail = r.message.detail;\n contributors = r.message.contributors;\n \n var txt = \'<br>This is Revision - \' + detail[0][0] + \' of \' + dn +\'.\' + \'<br>Last modified by \' + detail[0][1] + \' on \' + dateutil.str_to_user(detail[0][2])\n + \'<br><br>Contributors : \' + contributors.join(\', \');\n set_field_options(\'History HTML\', txt);\n }\n \n args = {};\n args.doc = doc; args.dt = dt; args.dn = dn;\n $c_obj(\'Wiki Control\',\'get_wiki_detail\', docstring(args),callback);\n}\n\n// showing page history (keep this we will use this later)\n/*\npscript.show_page_history = function(){\n if(!pscript.history_list){\n history_list = new Listing(\'\',1);\n history_list.colwidths = [\'30%\',\'30%\',\'40%\'];\n history_list.colnames = [\'Revision\', \'Date\', \'Modified By\'];\n pscript.history_list = history_list;\n }\n \n if(!pscript.history_div){ pscript.history_div = document.createElement(\'div\'); }\n pscript.history_div.innerHTML = \'\';\n\n pscript.history_list.get_query = function(){\n this.query = repl("select version_no, creation, modified_by, name from `tabWiki History` where reference=\'%(ref)s\' order by version_no desc", {\'ref\':pscript.cur_dn});\n this.query_max = repl("select count(name) from `tabWiki History` where reference=\'%(ref)s\'", {\'ref\':pscript.cur_dn});\n }\n \n pscript.history_list.show_cell = function(cell,ri,ci,d){\n if(ci==0){\n alert(d[ri][3]);\n \n var revision = $a(cell,\'span\',\'link_type\');\n revision.innerHTML = \'Revision - \' + d[ri][0];\n revision.name = d[ri][3];\n \n revision.onclick = function(){ alert(1); alert(this.name); }\n }\n \n if(ci==1){ cell.innerHTML = dateutil.str_to_user(d[ri][1]); }\n \n if(ci==2){ cell.innerHTML = d[ri][2]; }\n }\n \n pscript.history_list.make(pscript.history_div);\n \n pscript.history_list.run();\n \n pscript.history_list.onrun = function(){\n //set_field_options\n var df = get_field(pscript.cur_dt, \'History HTML\', pscript.cur_dn);\n if(df)df.options = pscript.history_div;\n alert(df.options);\n msgprint(df.options);\n refresh_field(\'History HTML\');\n }\n}\n\npscript.show_history_content = function(wh){\n alert(wh);\n}\n*/', 'modified': '2010-09-20 14:06:57', 'server_code_error': '<pre style="text-align: left;"></pre>', 'name_case': '', 'parenttype': None, 'read_only_onload': None, 'server_code_core': None, 'server_code_compiled': None, 'parent_node': None, 'parentfield': None}, {'cancel': None, 'amend': None, 'execute': None, 'modified_by': 'Administrator', 'name': 'PERM00526', 'parent': 'Wiki Page', 'read': 1, 'create': 1, 'creation': '2009-12-04 10:56:29', 'modified': '2009-12-09 18:18:55', 'submit': None, 'doctype': 'DocPerm', 'write': 1, 'idx': 1, 'parenttype': 'DocType', 'role': 'All', 'owner': 'Administrator', 'docstatus': 0, 'permlevel': 0, 'match': None, 'parentfield': 'permissions'}, {'no_copy': None, 'oldfieldtype': 'Data', 'creation': '2009-12-04 10:56:29', 'doctype': 'DocField', 'oldfieldname': 'page_name', 'owner': 'Administrator', 'reqd': None, 'in_filter': None, 'print_hide': None, 'modified_by': 'Administrator', 'label': 'Page Name', 'width': None, 'trigger': None, 'depends_on': None, 'docstatus': 0, 'hidden': None, 'permlevel': 0, 'description': None, 'parent': 'Wiki Page', 'search_index': None, 'allow_on_submit': None, 'icon': None, 'name': 'FL03472', 'idx': 1, 'default': None, 'colour': None, 'modified': '2009-12-09 18:18:55', 'parenttype': 'DocType', 'fieldname': 'page_name', 'fieldtype': 'Data', 'options': None, 'report_hide': None, 'parentfield': 'fields'}, {'no_copy': None, 'oldfieldtype': 'HTML', 'creation': '2009-12-04 10:56:29', 'doctype': 'DocField', 'oldfieldname': None, 'owner': 'Administrator', 'reqd': None, 'in_filter': None, 'print_hide': None, 'modified_by': 'Administrator', 'label': 'Heading', 'width': None, 'trigger': None, 'depends_on': None, 'docstatus': 0, 'hidden': None, 'permlevel': 0, 'description': None, 'parent': 'Wiki Page', 'search_index': None, 'allow_on_submit': None, 'icon': None, 'name': 'FL03473', 'idx': 2, 'default': None, 'colour': None, 'modified': '2009-12-09 18:18:55', 'parenttype': 'DocType', 'fieldname': None, 'fieldtype': 'HTML', 'options': '', 'report_hide': None, 'parentfield': 'fields'}, {'no_copy': None, 'oldfieldtype': 'Button', 'creation': '2009-12-04 10:56:29', 'doctype': 'DocField', 'oldfieldname': None, 'owner': 'Administrator', 'reqd': None, 'in_filter': None, 'print_hide': None, 'modified_by': 'Administrator', 'label': 'Done', 'width': None, 'trigger': 'Client', 'depends_on': None, 'docstatus': 0, 'hidden': None, 'permlevel': 0, 'description': None, 'parent': 'Wiki Page', 'search_index': None, 'allow_on_submit': None, 'icon': None, 'name': 'FL03474', 'idx': 3, 'default': None, 'colour': None, 'modified': '2009-12-09 18:18:55', 'parenttype': 'DocType', 'fieldname': None, 'fieldtype': 'Button', 'options': None, 'report_hide': None, 'parentfield': 'fields'}, {'no_copy': None, 'oldfieldtype': 'HTML', 'creation': '2009-12-04 10:56:29', 'doctype': 'DocField', 'oldfieldname': None, 'owner': 'Administrator', 'reqd': None, 'in_filter': None, 'print_hide': None, 'modified_by': 'Administrator', 'label': 'Page HTML', 'width': None, 'trigger': None, 'depends_on': None, 'docstatus': 0, 'hidden': None, 'permlevel': 0, 'description': None, 'parent': 'Wiki Page', 'search_index': None, 'allow_on_submit': None, 'icon': None, 'name': 'FL03475', 'idx': 4, 'default': None, 'colour': None, 'modified': '2009-12-09 18:18:55', 'parenttype': 'DocType', 'fieldname': None, 'fieldtype': 'HTML', 'options': '', 'report_hide': None, 'parentfield': 'fields'}, {'no_copy': None, 'oldfieldtype': 'Text Editor', 'creation': '2009-12-04 10:56:29', 'doctype': 'DocField', 'oldfieldname': 'editor', 'owner': 'Administrator', 'reqd': None, 'in_filter': None, 'print_hide': None, 'modified_by': 'Administrator', 'label': 'Editor', 'width': None, 'trigger': '', 'depends_on': None, 'docstatus': 0, 'hidden': None, 'permlevel': 0, 'description': None, 'parent': 'Wiki Page', 'search_index': None, 'allow_on_submit': None, 'icon': None, 'name': 'FL03476', 'idx': 5, 'default': None, 'colour': 'White:FFF', 'modified': '2009-12-09 18:18:55', 'parenttype': 'DocType', 'fieldname': 'editor', 'fieldtype': 'Text Editor', 'options': None, 'report_hide': None, 'parentfield': 'fields'}, {'no_copy': None, 'oldfieldtype': 'Button', 'creation': '2009-12-04 10:56:29', 'doctype': 'DocField', 'oldfieldname': None, 'owner': 'Administrator', 'reqd': None, 'in_filter': None, 'print_hide': None, 'modified_by': 'Administrator', 'label': 'Edit', 'width': None, 'trigger': 'Client', 'depends_on': None, 'docstatus': 0, 'hidden': None, 'permlevel': 0, 'description': None, 'parent': 'Wiki Page', 'search_index': None, 'allow_on_submit': None, 'icon': None, 'name': 'FL03477', 'idx': 6, 'default': None, 'colour': 'White:FFF', 'modified': '2009-12-09 18:18:55', 'parenttype': 'DocType', 'fieldname': None, 'fieldtype': 'Button', 'options': None, 'report_hide': None, 'parentfield': 'fields'}, {'no_copy': None, 'oldfieldtype': 'HTML', 'creation': '2009-12-04 10:56:29', 'doctype': 'DocField', 'oldfieldname': '', 'owner': 'Administrator', 'reqd': None, 'in_filter': None, 'print_hide': None, 'modified_by': 'Administrator', 'label': 'Footer HTML', 'width': None, 'trigger': None, 'depends_on': None, 'docstatus': 0, 'hidden': None, 'permlevel': 0, 'description': None, 'parent': 'Wiki Page', 'search_index': None, 'allow_on_submit': None, 'icon': None, 'name': 'FL03478', 'idx': 7, 'default': None, 'colour': None, 'modified': '2009-12-09 18:18:55', 'parenttype': 'DocType', 'fieldname': '', 'fieldtype': 'HTML', 'options': '<div style=\'border-top: 1px solid #AAA; margin-top: 32px; padding-top: 8px\'>To create / link another WIki Page, use <span style="font-family: Courier, fixed">$page(New Page Name)</span></div>\n\n<div>To add image, use <span style="font-family:Courier,fixed">$image(filename)</span></div>\n<!--\n<div><span class="link_type" onclick="pscript.show_page_history()">Show page history</span></div> -->', 'report_hide': None, 'parentfield': 'fields'}, {'no_copy': None, 'oldfieldtype': 'HTML', 'creation': '2009-12-07 16:49:50', 'doctype': 'DocField', 'oldfieldname': None, 'owner': 'Administrator', 'reqd': None, 'in_filter': None, 'print_hide': None, 'modified_by': 'Administrator', 'label': 'History HTML', 'width': None, 'trigger': None, 'depends_on': None, 'docstatus': 0, 'hidden': None, 'permlevel': 0, 'description': None, 'parent': 'Wiki Page', 'search_index': None, 'allow_on_submit': None, 'icon': None, 'name': 'FL03482', 'idx': 8, 'default': None, 'colour': None, 'modified': '2009-12-09 18:18:55', 'parenttype': 'DocType', 'fieldname': None, 'fieldtype': 'HTML', 'options': '', 'report_hide': None, 'parentfield': 'fields'}]
\ No newline at end of file
diff --git a/tools/page/__init__.py b/tools/page/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tools/page/__init__.py
diff --git a/tools/page/file_browser/__init__.py b/tools/page/file_browser/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tools/page/file_browser/__init__.py
diff --git a/tools/page/file_browser/file_browser.html b/tools/page/file_browser/file_browser.html
new file mode 100644
index 0000000..d30409e
--- /dev/null
+++ b/tools/page/file_browser/file_browser.html
@@ -0,0 +1,55 @@
+<div style="margin: 0px;">
+<div id="fb_header"> </div>
+<!--
+<table style="border: 1px solid #cccccc; width: 100%; background-color: #dfe1fd; vertical-align: middle; border-collapse: collapse;" border="0">
+<tbody>
+<tr>
+<td style="width: 70%; padding-left: 8px;">
+<h2>File Browser</h2>
+</td>
+<td style="width: 30%; text-align: right; padding-right: 8px; vertical-align: middle;"><span class="link_type" title="Close"> <img style="cursor:pointer" mce_style="cursor:pointer" onclick="nav_obj.show_last_open()" src="images/icons/close.gif" mce_src="images/icons/close.gif" alt="" /> </span></td>
+</tr>
+</tbody>
+</table>
+-->
+<div style="width: 100%;">
+<table style="border: 1px solid #cccccc; width: 100%; border-collapse: collapse;" border="0">
+<tbody>
+<tr>
+<td style="border: 1px solid #cccccc; padding: 8px; width: 40%; border-collapse: collapse;">
+<table style="width: 100%;" border="0">
+<tbody>
+<tr>
+<td id="fb_gen_action" style="width: 100%; vertical-align: middle;"> </td>
+</tr>
+<tr>
+<td id="fb_tree_div" style="width: 100%; padding-top: 20px;"> </td>
+</tr>
+</tbody>
+</table>
+</td>
+<td style="border: 1px solid #cccccc; padding: 8px; width: 60%; border-collapse: collapse;">
+<table style="width: 100%;" border="0">
+<tbody>
+<tr>
+<td id="fb_file_action" style="width: 100%; vertical-align: middle;"> </td>
+</tr>
+<tr>
+<td id="fb_grp_action" style="width: 100%; vertical-align: middle;"> </td>
+</tr>
+<tr>
+<td id="fb_display_div" style="width: 100%; vertical-align: middle;"> </td>
+</tr>
+<tr>
+<td id="unselect">
+<h2 style="color:#AAA">You have not selected anything.</h2>
+</td>
+</tr>
+</tbody>
+</table>
+</td>
+</tr>
+</tbody>
+</table>
+</div>
+</div>
\ No newline at end of file
diff --git a/tools/page/file_browser/file_browser.js b/tools/page/file_browser/file_browser.js
new file mode 100644
index 0000000..279bbed
--- /dev/null
+++ b/tools/page/file_browser/file_browser.js
@@ -0,0 +1,992 @@
+pscript['onload_File Browser'] = function(){
+
+ // header and toolbar
+ var h = new PageHeader('fb_header','File Management','Upload and share your file across users');
+ //$dh(h.toolbar); $y(h.toolbar,{width:'0px', height:'0px'})
+
+ if(!pscript.fb_tree)
+ pscript.create_browser_tree();
+ pscript.get_root_file_grps();
+
+ pscript.create_action_widget();
+ pscript.create_display_div();
+
+ pscript.create_n_file_grp_obj();
+ pscript.create_n_file_obj();
+ pscript.create_attach_obj();
+
+ pscript.get_all_roles();
+
+ $ds(pscript.gen_div);
+ $dh(pscript.grp_div);
+ $dh(pscript.file_div);
+
+ $ds($i('unselect'));
+}
+
+// Get all roles
+pscript.get_all_roles = function(){
+ if(!pscript.fg_all_roles){
+ var callback = function(r,rt){
+ pscript.fg_all_roles = r.message ? r.message : '';
+ pscript.create_share_obj();
+ pscript.fg_share.make(r.message);
+ }
+ $c_obj('File Browser Control','get_all_roles','',callback);
+ }
+}
+
+
+// Creating File Browser tree.
+pscript.create_browser_tree = function() {
+
+ $i('fb_tree_div').innerHTML = '';
+ var tree = new Tree($i('fb_tree_div'), '100%');
+ pscript.fb_tree = tree;
+
+ pscript.fb_tree.std_onclick = function(node) { /*pass*/ } // on click
+ pscript.fb_tree.std_onexp = function(node) { /*PASS*/ } // on expand
+
+ $ds(pscript.gen_div);
+ $dh(pscript.grp_div);
+ $dh(pscript.file_div);
+
+ $dh(pscript.f_file_display);
+}
+
+// Creating a Share Privilege object.
+pscript.create_share_obj = function(){
+
+ var d = new Dialog(400,400,'Assign Privilege');
+ var me = d;
+ d.inputs = {};
+
+ d.make_body([
+ ['HTML','Privilege','<div id="fg_share_div" style="overflow-y:auto; height:300px"></div>'],
+ ['Button','Update']
+ ]);
+
+
+ d.make = function(all_roles){
+ optn_header = make_table('fg_share_div',1,2,'100%',['60%','40%'],{padding:'4px'});
+
+ for(var c=0;c<2;c++){
+ if(c==1)
+ $td(optn_header,0,c).innerHTML = '<b>Privilege</b>';
+ else
+ $td(optn_header,0,c).innerHTML = '<b>Role</b>';
+ }
+
+ optn_tbl = make_table('fg_share_div',all_roles.length,2,'100%',['60%','40%'],{padding:'4px'});
+
+ for(var i=0;i<all_roles.length;i++){
+
+ var v=$a($td(optn_tbl, i,0),'div');
+ v.innerHTML=all_roles[i];
+
+ // make select
+ var sel = $a($td(optn_tbl, i,1),'select');
+ add_sel_options(sel,['None','Edit','View'],'None');
+
+ sel.r_nm = all_roles[i];
+ d.inputs[sel.r_nm] = sel;
+
+ sel.onchange = function(){}
+ }
+ }
+
+ // Assigning roles in Share Privilege object.
+ d.assign = function(all_roles,edit_roles,view_roles){
+
+ if(all_roles == undefined) all_roles = '';
+ if(edit_roles == undefined) edit_roles = '';
+ if(view_roles == undefined) view_roles = '';
+
+ for(var i=0;i<all_roles.length;i++){
+ var ele = all_roles[i];
+ var sel = me.inputs[ele];
+
+ if(in_list(edit_roles,ele))
+ sel.value = 'Edit';
+ else if(in_list(view_roles,ele))
+ sel.value = 'View';
+ else
+ sel.value = 'None';
+ }
+ }
+
+ //on update
+ d.widgets['Update'].onclick = function(){
+ var edit_roles = []; var view_roles = [];
+
+ for(var i=0;i<pscript.fg_all_roles.length;i++){
+ var ele = pscript.fg_all_roles[i]; var sel = me.inputs[ele];
+
+ if(sel_val(sel) == 'Edit')
+ edit_roles.push(ele)
+ else if(sel_val(sel) == 'View')
+ view_roles.push(ele)
+ }
+
+ var args = {}; args.name = pscript.f_cur_node_name; args.type = pscript.f_cur_node_type;
+ args.edit_roles = edit_roles.join(','); args.view_roles = view_roles.join(',');
+
+ $c_obj('File Browser Control','update_privileges',docstring(args),function(r,rt){me.hide();});
+ }
+
+ d.onshow = function(){}
+ d.onhide = function(){}
+ pscript.fg_share = d;
+}
+
+// Action Widget
+pscript.create_action_widget = function(){
+
+ // General Actions.
+ // new action widget
+ pscript.gen_div = $i('fb_gen_action');
+
+ //refresh tree
+ f_refresh = $a(pscript.gen_div,'span','',{marginRight:'15px'});
+ f_refresh.innerHTML = '<img src="images/icons/page_refresh.gif" style="margin-right:5px; vertical-align:middle"/><span class="link_type" style="vertical-align:middle">Refresh</span>';
+ f_refresh.onclick = function(){
+ pscript.fb_refresh();
+ $dh(pscript.f_file_display);
+ }
+
+ // new group
+ f_new_grp = $a(pscript.gen_div,'span','',{marginRight:'15px'});
+ f_new_grp.innerHTML = '<img src="images/icons/folder.gif" style="margin-right: 5px; vertical-align:middle"><span class="link_type" style="vertical-align:middle">New</span>';
+ f_new_grp.onclick = function(){ pscript.fb_show_grp(''); $ds(pscript.f_file_display); $dh($i('unselect')); }
+
+ // Group actions.
+ pscript.grp_div = $i('fb_grp_action');
+
+ // share group
+ f_share_grp = $a(pscript.grp_div,'span','',{marginRight:'15px'});
+ f_share_grp.innerHTML = '<img src="images/icons/user.png" style="margin-right: 5px; vertical-align:middle"><span class="link_type" style="vertical-align:middle">Share</span>';
+ f_share_grp.onclick = function(){ pscript.fb_share(); }
+
+ //Delete group.
+ f_del_grp = $a(pscript.grp_div,'span','',{marginRight:'15px'});
+ f_del_grp.innerHTML = '<img src="images/icons/cancel.gif" style="margin-right: 5px; vertical-align:middle"><span class="link_type" style="vertical-align:middle">Delete</span>';
+ f_del_grp.onclick = function(){ pscript.fb_delete(); }
+
+ // Add file to group.
+ f_new_file = $a(pscript.grp_div,'span','',{marginRight:'15px'});
+ f_new_file.innerHTML = '<img src="images/icons/page_add.gif" style="margin-right: 5px; vertical-align:middle"><span class="link_type" style="vertical-align:middle">Upload</span>';
+ f_new_file.onclick = function(){ pscript.fb_create_new_file(); }
+ // $dh(f_new_file);
+
+ // file actions
+ pscript.file_div = $i('fb_file_action');
+
+
+ //share file
+ f_share_file = $a(pscript.file_div,'span','',{marginRight:'15px'});
+ f_share_file.innerHTML = '<img src="images/icons/user.png" style="margin-right: 5px; vertical-align:middle"><span class="link_type" style="vertical-align:middle">Share</span>';
+ f_share_file.onclick = function(){ pscript.fb_share(); };
+
+ // delete file
+ f_del_file = $a(pscript.file_div,'span','',{marginRight:'15px'});
+ f_del_file.innerHTML = '<img src="images/icons/cancel.gif" style="margin-right: 5px; vertical-align:middle"><span class="link_type" style="vertical-align:middle">Delete</span>';
+ f_del_file.onclick = function(){ pscript.fb_delete(); };
+
+
+ //edit file
+ f_edit_file = $a(pscript.file_div,'span','',{marginRight:'15px'});
+ f_edit_file.innerHTML = '<img src="images/icons/table_edit.png" style="margin-right: 5px; vertical-align:middle"><span class="link_type" style="vertical-align:middle">Edit</span>';
+ f_edit_file.onclick = function(){ pscript.fb_edit_file(); };
+}
+
+
+// Refresh tree
+pscript.fb_refresh = function(){
+ pscript.create_browser_tree();
+ pscript.get_root_file_grps();
+
+ $ds(pscript.gen_div);
+ $dh(pscript.grp_div);
+ $dh(pscript.file_div);
+
+ if(!pscript.f_cur_node_name){ $dh($i('unselect')); } else{ $ds($i('unselect')); }
+}
+
+// Show selected / create a new file group.
+pscript.fb_show_grp = function(grp){
+ var parent = pscript.f_file_display;
+
+ if(!grp || grp == undefined){
+ parent.f_file_title.innerHTML = 'New File Group';
+ pscript.n_file_grp.show('');
+ }
+ else{
+ var callback = function(r,rt){
+
+ var grp_det = r.message ? r.message : '';
+
+ parent.f_file_title.innerHTML = grp_det['Group Name'];
+ if(has_common(grp_det['Can Edit'].split(','),user_roles) || user==grp_det['Owner']){ $ds(pscript.grp_div); }
+ else{ $dh(pscript.grp_div); }
+
+ pscript.n_file_grp.show(grp_det);
+ }
+ $c_obj('File Browser Control','get_fg_details',grp,callback);
+ }
+ $ds(parent); $ds(parent.f_file_content);
+}
+
+//share privileges.
+pscript.fb_share = function(){
+ var callback = function(r,rt){
+ pscript.fg_edit_roles = r.message[0][0] ? r.message[0][0].split(',') : '';
+ pscript.fg_view_roles = r.message[0][1] ? r.message[0][1].split(',') : '';
+
+ pscript.fg_share.assign(pscript.fg_all_roles,pscript.fg_edit_roles,pscript.fg_view_roles);
+ pscript.fg_share.show();
+ }
+ var args = {};
+ args.dt = pscript.f_cur_node_type;
+ args.dn = pscript.f_cur_node_name;
+ $c_obj('File Browser Control','get_privileges',docstring(args),callback);
+}
+
+// delete group
+pscript.fb_delete = function(){
+ pscript.delete_node('File Browser Control',pscript.f_cur_node_type,pscript.f_cur_node_name,'');
+ $dh(pscript.f_file_display);
+}
+
+// Create a new file.
+pscript.fb_create_new_file = function(){
+ var parent = pscript.f_file_display;
+
+ pscript.f_cur_parent = pscript.f_cur_node;
+
+ parent.f_file_title.innerHTML = 'New File';
+ pscript.n_file.show(0,'frm_node');
+}
+
+// If file other than image then download file.
+pscript.fb_show_txt_file = function(){
+ $i('file_link').href = repl('cgi-bin/getfile.cgi?ac=%(acc)s&name=%(f_nm)s',{acc:session.account_name, f_nm:pscript.f_cur_node_file});
+ $i('file_link').target = "_blank";
+}
+
+// Area to display content.
+pscript.create_display_div = function(){
+
+ var d = $a($i('fb_display_div'),'div');
+
+ d.f_file_title = $a(d,'div','',{fontSize:'14px',fontWeight:'bold'});
+ $y($a(d,'div'),{margin:'5px 0px 5px 0px',borderBottom:'1px solid #333'});
+
+ d.f_file_content = $a(d,'div','',{marginTop:'20px'});
+ pscript.f_file_display = d;
+ $dh(d);
+}
+
+// function to create a new File Group object.
+pscript.create_n_file_grp_obj = function(){
+ var n_file_grp = new pscript.n_file_grp_Obj();
+ pscript.n_file_grp = n_file_grp;
+}
+
+// Create a new File object.
+pscript.create_n_file_obj = function(){
+ var n_file = new pscript.n_file_Obj();
+ pscript.n_file = n_file;
+}
+
+// Create a new Attachement object.
+pscript.create_attach_obj = function(){
+ var attach_obj = new pscript.attach_Obj();
+ pscript.attach_obj = attach_obj;
+}
+
+// File Group object.
+pscript.n_file_grp_Obj = function() {
+
+ this.inputs = {}; var me = this; this.fg_field_lst = [];
+
+ this.make_section = function(label, tp, css) {
+
+ var div = $a(this.wrapper,'div','',{marginBottom:'8px'});
+ var t = make_table(div,1,2,'90%',['35%','65%']);
+
+ if(tp=='button'){
+ var element = $a($td(t,0,1), 'button', 'button');
+ element.innerHTML = label;
+ }
+ else if(tp == 'link'){
+ var element = make_field({fieldtype:'link', 'label':label, 'options':'File Group'}, '', $td(t,0,1), this, 0, 1);
+ $y($td(t,0,1),{width:'100%'})
+ element.in_filter = 1; element.refresh();
+
+ $td(t,0,0).innerHTML = label;
+ element.display_div = $a($td(t,0,1),'div', '', {width:'80%'});
+ me.fg_field_lst.push(label);
+ }
+ else {
+ var element = $a($td(t,0,1),tp, '', {width:'80%'});
+ $td(t,0,0).innerHTML = label;
+
+ element.display_div = $a($td(t,0,1),'div', '', {width:'80%'});
+ $dh(element.display_div);
+ me.fg_field_lst.push(label);
+ }
+
+ if(css){
+ $y($td(t,0,0),css);
+ }
+
+ element.wrapper = div;
+
+ if(label) me.inputs[label] = element;
+ return element;
+ }
+
+ this.make = function() {
+
+ this.wrapper = document.createElement('div');
+
+ this.make_section('Group Name','input',{color:'red'});
+ this.make_section('Parent Group','link');
+ this.make_section('Description','textarea');
+ $y(this.inputs['Description'],{height:'140px'});
+
+ this.make_section('Save','button');
+
+ // cancel
+ this.inputs['Cancel'] = $a(this.inputs['Save'].parentNode, 'button', 'button');
+ this.inputs['Cancel'].innerHTML = 'Cancel';
+ $y(this.inputs['Cancel'], {marginLeft:'8px'});
+ }
+
+ this.show = function(grp_det){
+
+ if(! me.wrapper) me.make();
+
+ var field_lst = me.fg_field_lst;
+
+ if(!grp_det || grp_det == undefined){
+ pscript.fg_edit_roles = ''; pscript.fg_view_roles = ''; me.inputs['Save'].disabled = false;
+
+ for(i in field_lst){
+ var fld_nm = field_lst[i] ? field_lst[i] : '';
+ var fld = me.inputs[fld_nm] ? me.inputs[fld_nm] : '';
+ fld.display_div.innerHTML = '';
+
+ if(fld_nm == 'Parent Group'){ fld.txt.value = ''; $ds(fld.input_area); }
+ else{ fld.value = ''; $ds(fld); }
+
+ $dh(fld.display_div);
+ }
+ me.inputs['Save'].onclick = function(){ me.save(''); }
+ }
+ else{
+ pscript.fg_edit_roles = grp_det['Can Edit'] ? grp_det['Can Edit'].split(',') : '';
+ pscript.fg_view_roles = grp_det['Can View'] ? grp_det['Can View'].split(',') : '';
+ for(i in field_lst){
+ var fld_nm = field_lst[i] ? field_lst[i] : '';
+ var fld = me.inputs[fld_nm] ? me.inputs[fld_nm] : '';
+ fld.display_div.innerHTML = grp_det[fld_nm] ? grp_det[fld_nm] : '';
+
+ if(fld_nm == 'Parent Group') fld.txt.value = grp_det[fld_nm] ? grp_det[fld_nm] : '';
+ else fld.value = grp_det[fld_nm] ? grp_det[fld_nm] : '';
+
+ if(has_common(pscript.fg_edit_roles,user_roles) || user == grp_det['Owner']){
+ if(fld_nm == 'Parent Group') $ds(fld.input_area); else $ds(fld);
+ $dh(fld.display_div); me.inputs['Save'].disabled = false;
+ }
+ else{
+ if(fld_nm == 'Parent Group') $dh(fld.input_area); else $dh(fld);
+ $ds(fld.display_div); me.inputs['Save'].disabled = true;
+ }
+ }
+ me.inputs['Save'].onclick = function(){ me.save(grp_det['Name']); }
+ }
+ me.show_as();
+ me.inputs['Cancel'].onclick = function() { me.cancel(); me.hide();}
+ }
+
+ this.save = function(name) {
+ var grp_nm = me.inputs['Group Name'].value; grp_nm = strip(grp_nm," ");
+ var parent_grp = me.inputs['Parent Group'].get_value(); parent_grp = strip(parent_grp," ");
+ var desc = me.inputs['Description'].value; desc = strip(desc," ");
+
+ if(grp_nm == '') msgprint('Please enter group name');
+ else{ var args = {}; args.grp_nm = grp_nm; args.parent_grp = parent_grp; args.desc = desc; }
+
+ if(!name || name == undefined){
+ args.name = '';
+ var callback = function(r,rt){
+ pscript.f_cur_node_name = r.message ? r.message : '';
+ pscript.fb_show_grp(pscript.f_cur_node_name);
+ pscript.fb_refresh();
+ //if(!pscript.f_cur_parent){ pscript.fb_refresh(); pscript.f_cur_node_name = }
+ //else{ pscript.load_child_nodes(); }
+ }
+ $c_obj('File Browser Control','create_new_grp',docstring(args),callback);
+ }
+ else{
+ args.name = name;
+ var callback = function(r,rt){
+ var grp = r.message ? r.message : '';
+ pscript.fb_show_grp(grp);
+ pscript.fb_refresh();
+ }
+ $c_obj('File Browser Control','update_grp',docstring(args),callback);
+ }
+
+ }
+
+ this.cancel = function(){
+ $dh(pscript.f_file_display);this.hide();
+ }
+
+ this.show_as = function() {
+ if(me.wrapper.parentNode) me.wrapper.parentNode.removeChild(me.wrapper);
+
+ var parent = pscript.f_file_display;
+ pscript.remove_child_nodes(parent.f_file_content);
+
+ parent.f_file_content.appendChild(me.wrapper);
+ $ds(pscript.f_file_display); $ds(me.wrapper);
+ }
+
+ this.hide = function() {
+ $dh(me.wrapper); me.display = 0;
+ }
+}
+
+// File Object.
+pscript.n_file_Obj = function() {
+
+ this.inputs = {};
+ var me = this;
+
+ this.make_section = function(label, tp, css) {
+
+ var div = $a(this.wrapper,'div','',{marginBottom:'8px'});
+ var t = make_table(div,1,2,'90%',['38%','62%']);
+
+ if(tp=='button'){
+ var element = $a($td(t,0,1), 'button', 'button');
+ element.innerHTML = label;
+ }
+ else if(tp=='Note'){
+ var element = $a($td(t,0,1),'span','',{color:'red'});
+ element.innerHTML = 'Fields in red are mandatory.'
+ }
+ else if(tp=='link'){
+ var element = make_field({fieldtype:'link', 'label':label, 'options':'File Group'}, '', $td(t,0,1), this, 0, 1);
+ $y($td(t,0,1),{width:'100%'})
+ element.in_filter = 1; element.refresh();
+
+ $td(t,0,0).innerHTML = label;
+ element.display_div = $a($td(t,0,1),'div', '', {width:'80%'});
+ element.txt.onchange = function(){ pscript.set_file_det_value(pscript.attach_obj,pscript.n_file); }
+ }
+ else {
+ var element = $a($td(t,0,1),tp, '', {width:'95%'});
+ $td(t,0,0).innerHTML = label;
+ element.onchange = function(){ pscript.set_file_det_value(pscript.attach_obj,pscript.n_file); }
+ }
+
+ //---css to label---
+ if(css){
+ $y($td(t,0,0),css);
+ }
+
+ element.wrapper = div;
+
+ if(label) me.inputs[label] = element;
+ return element;
+ }
+
+ this.make = function() {
+
+ this.wrapper = document.createElement('div');
+
+ // note
+ this.make_section('','Note');
+
+ // upload area
+ this.ul_area = $a(this.wrapper,'div','',{marginBottom:'8px'});
+ $dh(this.ul_area);
+
+ // file group and description
+ this.make_section('File Group','link',{color:'red'});
+ this.make_section('Description','textarea');
+ $y(this.inputs['Description'],{height:'140px'});
+
+ //save
+ this.make_section('Save','button');$dh(this.inputs['Save']);
+
+ // cancel
+ this.inputs['Cancel'] = $a(this.inputs['Save'].parentNode, 'button', 'button');
+ this.inputs['Cancel'].innerHTML = 'Cancel'; $dh(this.inputs['Cancel']);
+ $y(this.inputs['Cancel'], {marginLeft:'8px'});
+ }
+
+ this.show = function(edit,frm){
+ if(! me.wrapper) me.make();
+
+ if(edit){
+ var callback1 = function(r,rt){
+ file_det = r.message;
+
+ me.inputs['Description'].value = file_det['description'] ? file_det['description'] : '';
+ me.inputs['File Group'].txt.value = file_det['file_group'] ? file_det['file_group'] : '';
+
+ pscript.f_cur_node_file = file_det['file_list'] ? file_det['file_list'].split(NEWLINE)[0].split(',')[1] : '';
+
+ me.inputs['Save'].file_id = file_det['name'] ? file_det['name'] : '';
+ me.inputs['Save'].onclick = function(){ me.save(this.file_id);}
+ pscript.attach_obj.show(me, me.ul_area, 1, file_det);
+ }
+ $ds(me.ul_area); $di(me.inputs['Save']); $di(me.inputs['Cancel']);
+ $c_obj('File Browser Control','get_file_details',pscript.f_cur_node_name,callback1);
+ }
+ else{
+ $ds(me.ul_area); $dh(me.inputs['Save']); $dh(me.inputs['Cancel']);
+
+ me.inputs['Description'].value = '';
+ if(frm == 'frm_node') me.inputs['File Group'].txt.value = pscript.f_cur_node_label;
+ var parent = pscript.f_file_display;
+ parent.f_file_title.innerHTML = 'New File';
+
+ $ds(parent);
+ me.inputs['Save'].onclick = function(){ me.save('');}
+ pscript.attach_obj.show(me,me.ul_area,0,'');
+ }
+ me.inputs['Cancel'].onclick = function() { me.cancel(); me.hide(); }
+ }
+
+ this.save = function(name) {
+
+ var desc = me.inputs['Description'].value; desc = strip(desc," ");
+ file_grp = me.inputs['File Group'].txt.value; file_grp = strip(file_grp," ");
+
+ if(file_grp == '') msgprint('Please select file group');
+
+ var args = {}; args.desc = desc; args.file_grp = file_grp;
+
+ if(name){
+ args.name = name;
+ var callback = function(){
+ //pscript.fb_edit_file();
+
+ //refreshing parent
+ pscript.load_child_nodes();
+ }
+ $c_obj('File Browser Control','update_file',docstring(args),callback);
+ }
+ else{
+ args.name = ''
+ var callback = function(r,rt){
+ var f = eval('var a='+r.message+';a');
+
+ //refreshing node
+ pscript.load_child_nodes();
+
+ //pscript.f_cur_node_name = f.name; pscript.f_cur_node_label = f.label;
+ //pscript.fb_edit_file();
+ }
+ $c_obj('File Browser Control','create_new_file',docstring(args),callback);
+ }
+ }
+
+ this.cancel = function(){
+ $dh(pscript.f_file_display); this.hide();
+ }
+
+ this.show_as = function(edit) {
+ if(me.wrapper.parentNode) me.wrapper.parentNode.removeChild(me.wrapper);
+
+ var parent = pscript.f_file_display;
+ pscript.remove_child_nodes(parent.f_file_content);
+
+ parent.f_file_content.appendChild(me.wrapper);
+ $ds(pscript.f_file_display); $ds(parent.f_file_content);
+ $ds(me.wrapper);
+ }
+
+ this.hide = function() {
+ $dh(me.wrapper);
+ me.display = 0;
+ }
+}
+
+// File Attachement object.
+pscript.attach_Obj = function(){
+
+ var me = this;
+
+ this.show = function(obj,parent,edit,dict){
+ var me = this;
+ if(!me.wrapper) { me.make(); }
+
+ me.show_as(obj,parent,edit,dict);
+ obj.show_as(edit);
+ }
+
+ this.make = function(){
+ var me = this;
+ this.wrapper = document.createElement('div');
+
+ var div = $a(this.wrapper,'div',{marginBottom:'8px', border:'1px solid #AAA'});
+
+ var t1 = make_table(div,1,2,'90%',['38%','62%']);
+
+ lbl_area = $a($td(t1,0,0),'div');
+ lbl_area.innerHTML = '<img src="images/icons/paperclip.gif"><span style="margin-left4px; color:red;">File:</span><br>';
+
+ main_area = $a($td(t1,0,1),'div');
+
+ this.upload_div = $a(main_area,'div');
+ this.download_div = $a(main_area,'div');
+
+ me.make_ul_area();
+ me.make_dl_area();
+ }
+
+ //image upload area
+ this.make_ul_area = function(){
+ var me = this;
+
+ this.upload_div.innerHTML = '';
+
+ var div = $a(this.upload_div,'div');
+ div.innerHTML = '<iframe id="fb_iframe" name="fb_iframe" src="blank1.html" style="width:0px; height:0px; border:0px"></iframe>';
+
+ var div = $a(this.upload_div,'div');
+ div.innerHTML = '<form method="POST" enctype="multipart/form-data" action="'+outUrl+'" target="fb_iframe"></form>';
+
+ var ul_form = div.childNodes[0];
+
+ this.upload_div.ul_form = ul_form;
+
+ var f_list = [];
+
+ // file data
+ var inp_fdata = $a_input($a(ul_form,'span'),'file',{name:'filedata'});
+
+ var inp_btn = $a_input($a(ul_form,'span'),'hidden',{name:'cmd'}); inp_btn.value = 'upload_many';
+ var inp = $a_input($a(ul_form,'span'),'hidden',{name:'form_name'}); inp.value = 'File Browser';
+ var inp = $a_input($a(ul_form,'span'),'submit'); inp.value = 'Upload';
+
+ this.inp_file = $a_input($a(ul_form,'span'),'hidden',{name:'file_id'});
+ this.file_det = $a_input($a(ul_form,'span'),'hidden',{name:'file_det'});
+
+ inp_btn.onclick = function(){
+ pscript.set_file_det_value(pscript.attach_obj,pscript.n_file);
+ }
+ }
+
+ //download link
+ this.make_dl_area = function(){
+ var me = this;
+ var download_tbl = make_table(this.download_div,1,2,'100%',['70%','30%']);
+
+ var download_link = $a($td(download_tbl,0,0),'a','link_type');
+
+ this.download_div.download_link = download_link;
+
+ var remove_link = $a($td(download_tbl,0,1),'span','link_type',{textAlign:'right',marginLeft:'20px'});
+ remove_link.innerHTML = 'Remove';
+
+ this.download_div.remove_link = remove_link;
+ }
+
+ this.show_as = function(obj,parent,edit,dict){
+ var me = this;
+
+ // add to parent
+ if(me.wrapper.parentNode) me.wrapper.parentNode.removeChild(me.wrapper);
+ parent.appendChild(me.wrapper);
+ $ds(me.wrapper);
+
+ if(edit){
+ pscript.set_file_det_value(pscript.attach_obj,pscript.n_file);
+ me.inp_file.value = dict.name ? dict.name : '';
+
+ if(dict.file_list){ $dh(me.upload_div); $ds(me.download_div); }
+ else{ $ds(me.upload_div); $dh(me.download_div); }
+
+ // download
+ me.download_div.download_link.innerHTML = dict.file_list ? dict.file_list.split(',')[0] : '';
+ me.download_div.download_link.onclick = function(){
+ this.href = repl('cgi-bin/getfile.cgi?ac=%(acc)s&name=%(f_nm)s',{acc:session.account_name, f_nm:pscript.f_cur_node_file});
+ this.target = "_blank";
+ }
+
+ // remove
+ me.download_div.remove_link.onclick = function(){
+ $c_obj('File Browser Control','remove_file',docstring(dict),function(r,rt){
+ pscript.n_file.show(0,'frm_remove');
+ });
+ $ds(me.upload_div); $dh(me.download_div);
+ }
+ }
+ else{
+ $ds(me.upload_div); $dh(me.download_div);
+ me.inp_file.value = '';
+ pscript.set_file_det_value(pscript.attach_obj,pscript.n_file);
+ }
+ }
+}
+
+// Get all root file groups(where Parent Group is null).
+pscript.get_root_file_grps = function(){
+
+ if (pscript.fb_tree){
+ pscript.fb_tree.body.innerHTML = '';
+ }
+
+ var callback1 = function(r,rt){
+ var cl = r.message ? r.message : ''; var n = pscript.fb_tree.allnodes[cl]; var has_children = true;
+
+ for(var i=0; i<cl.length;i++){
+ if(!cl[i][2] || cl[i][2] == undefined) cl[i][2] = ''; if(!cl[i][3] || cl[i][3] == undefined) cl[i][3] = '';
+ if(has_common(cl[i][2].split(','),user_roles) || has_common(cl[i][3].split(','),user_roles) || user == cl[i][4]){
+ var r = pscript.fb_tree.addNode(null, cl[i][0],'', pscript.show_hide_link , has_children ? pscript.fb_get_children : null, null, cl[i][1]);
+ r.rec = cl[i]; r.rec.name = cl[i][0]; r.rec.label = cl[i][1]; r.rec.parent_grp = ''; r.rec.file_list = ''; r.rec.type = 'File Group';
+ }
+ }
+ }
+ $c_obj('File Browser Control','get_root_file_grps','',callback1);
+}
+
+// Onclick of a tree node will show / hide corresponding actions from action widget.
+pscript.show_hide_link = function(node){
+
+ $dh($i('unselect'));
+ $dh(pscript.f_file_display);
+
+ pscript.f_cur_node = node;
+
+ if(node.parent){
+ pscript.f_cur_parent = node.parent;
+ }
+ else{ pscript.f_cur_parent = ''; }
+
+ pscript.f_cur_node_name = node.rec.name;
+
+ if(node.rec.label){ pscript.f_cur_node_label = node.rec.label; }
+ else{ pscript.f_cur_node_label = ''; }
+
+ if(node.rec.type){ pscript.f_cur_node_type = node.rec.type; }
+ else{ pscript.f_cur_node_type = ''; }
+
+ if(node.rec.file_list){ pscript.f_cur_node_file = node.rec.file_list.split(NEWLINE)[0].split(',')[1]; }
+ else{ pscript.f_cur_node_file = ''; }
+
+ img_extns = ['jpg','jpeg','gif','png','biff','cgm','dpof','exif','img','mng','pcx','pic','pict','raw','tga','wmf']
+ extn = node.rec.file_list ? node.rec.file_list.split(NEWLINE)[0].split(',')[0].split('.')[1] : '';
+
+ var dsp_div = pscript.f_file_display;
+ dsp_div.f_file_title.innerHTML = pscript.f_cur_node_label;
+
+ if(node.rec.type == 'File Group'){
+ $dh(pscript.file_div);
+ $ds(pscript.grp_div);
+ pscript.fb_show_grp(pscript.f_cur_node_name);
+ }
+ else if(node.rec.type == 'File'){
+ $dh(pscript.grp_div);
+ $ds(pscript.file_div);
+ if(pscript.f_cur_node_file){
+ if(inList(img_extns,extn)){
+ pscript.fb_show_img();
+ }
+ else{
+ // IE FIX
+ pscript.remove_child_nodes(dsp_div.f_file_content);
+
+ var div = document.createElement('div');
+ div.innerHTML = '<a class="link_type" onclick="pscript.fb_show_txt_file()" id="file_link">Click to Open/ Download file.</span>';
+ dsp_div.f_file_content.appendChild(div);
+ $ds(dsp_div);
+ }
+ }
+ else{
+ dsp_div.f_file_content.innerHTML = 'No attachement found.';
+ $ds(pscript.f_file_display);
+
+ $ds(pscript.file_div);
+ $dh(pscript.grp_div);
+ }
+ pscript.show_edit_file_link(node.rec.name);
+ }
+ else{
+ $dh(pscript.grp_div);
+ $dh(pscript.file_div);
+ }
+}
+
+// Onexpand of a tree node get all childrens(Files / File Groups).
+pscript.fb_get_children = function(node){
+ if(node.expanded_once) return;
+ $ds(node.loading_div);
+
+ var callback = function(r,rt){
+ var p = pscript.fb_tree.allnodes[r.message.parent_grp];
+ $dh(node.loading_div);
+
+ var fl = r.message.fl ? r.message.fl : '';
+ if(fl){
+ for(var i=0; i<fl.length; i++){
+ if(fl[i][3] == undefined) fl[i][3] = '';
+ if(fl[i][4] == undefined) fl[i][4] = '';
+
+ if(has_common(fl[i][3].split(','),user_roles) || has_common(fl[i][4].split(','),user_roles) || (user == fl[i][5])){
+ var imgsrc = 'images/icons/page.gif'; var has_children = false;
+ if(fl[i][1]) var label = fl[i][1]; else var label = fl[i][0];
+
+ var n = pscript.fb_tree.addNode(p,fl[i][0],imgsrc,pscript.show_hide_link,has_children ? pscript.fb_get_children:null,null,label);
+ n.rec = fl[i]; n.rec.name = fl[i][0]; n.rec.parent_grp = r.message.parent_grp;
+ n.rec.label = fl[i][1]; n.rec.file_list = fl[i][2]; n.rec.type = 'File';
+ }
+ }
+ }
+
+ var fl_grp = r.message.fl_grp ? r.message.fl_grp : '';
+ if(fl_grp){
+ for(var i=0;i<fl_grp.length;i++){
+ if(fl_grp[i][2] == undefined) fl_grp[i][2] = '';
+ if(fl_grp[i][3] == undefined) fl_grp[i][3] = '';
+
+ if(has_common(fl_grp[i][2].split(','),user_roles) || has_common(fl_grp[i][3].split(','),user_roles) || (user == fl_grp[i][4])){
+ var imgsrc = 'images/icons/folder.gif'; var has_children = true;
+ var label = fl_grp[i][1] ? fl_grp[i][1] : fl_grp[i][0];
+
+ var n = pscript.fb_tree.addNode(p,fl_grp[i][0],imgsrc,pscript.show_hide_link,has_children ? pscript.fb_get_children:null,null,label);
+ n.rec = fl_grp[i]; n.rec.name = fl_grp[i][0]; n.rec.parent_grp = r.message.parent_grp;
+ n.rec.label = fl_grp[i][1]; n.rec.file_list = ''; n.rec.type='File Group';
+ }
+ }
+ }
+ }
+ $c_obj('File Browser Control','get_children',node.rec.name,callback);
+}
+
+// If image file then display image.
+pscript.fb_show_img = function(){
+
+ var parent = pscript.f_file_display;
+
+ parent.f_file_title.innerHTML = pscript.f_cur_node_label;
+ pscript.remove_child_nodes(parent.f_file_content);
+
+ var a = $a(parent.f_file_content,'a');
+
+ var img = $a(a,'img','',{textAlign:'center',cursor:'pointer'});
+ img.src = repl('cgi-bin/getfile.cgi?ac=%(acc)s&name=%(f_nm)s&thumbnail=300',{acc:session.account_name, f_nm:pscript.f_cur_node_file});
+ $ds(pscript.f_file_display);
+
+ a.onclick = function(){
+ this.href = repl('cgi-bin/getfile.cgi?ac=%(acc)s&name=%(f_nm)s',{acc:session.account_name, f_nm:pscript.f_cur_node_file});
+ this.target = "_blank";
+ }
+}
+
+// Enable/ disable Edit File action.
+pscript.show_edit_file_link = function(){
+
+ var callback = function(r,rt){
+ pscript.f_edit_roles = r.message[0][0] ? r.message[0][0].split(',') : '';
+ pscript.f_view_roles = r.message[0][1] ? r.message[0][1].split(',') : '';
+
+ if(has_common(pscript.f_edit_roles,user_roles) || user == r.message[0][2]){
+ $ds(pscript.file_div);
+ }
+ else{ $dh(pscript.file_div); }
+ }
+
+ var args = {};
+ args.dt = pscript.f_cur_node_type;
+ args.dn = pscript.f_cur_node_name;
+ $c_obj('File Browser Control','get_privileges',docstring(args),callback);
+}
+
+// Set file detail in attachement object.
+pscript.set_file_det_value = function(att,file){
+ if(file.inputs['Description'].value) file_desc = file.inputs['Description'].value; else file_desc = 'NIL';
+ if(file.inputs['File Group'].txt.value) file_grp = file.inputs['File Group'].txt.value; else file_grp = 'NIL';
+ att.file_det.value = file_desc + '~~' + file_grp;
+}
+
+// Edit selected file.
+pscript.fb_edit_file = function(){
+ var parent = pscript.f_file_display;
+ parent.f_file_title.innerHTML = pscript.f_cur_node_label;
+ pscript.n_file.show(1,'frm_node');
+}
+
+//delete dialog structure
+
+pscript.delete_node = function(sdt,dt,dn,callback){
+ if(!pscript.delete_dialog){
+ var delete_dialog = new Dialog(400,200);
+
+ delete_dialog.make_body([
+ ['HTML','Message',''],
+ ['HTML','Response',''],
+ ['HTML','Delete Record','<div id="delete_record" style="height:25px"></div>']
+ ]);
+
+ delete_dialog.y_btn = $a($i('delete_record'),'button','button');
+ delete_dialog.y_btn.innerHTML = 'Ok';
+ delete_dialog.y_btn.onclick = function(){
+ delete_dialog.widgets['Response'].innerHTML = 'Deleting...';
+ var args = {};
+ args.dt = delete_dialog.dt; args.dn = delete_dialog.dn;
+
+ var callback1 = function(r,rt){
+ delete_dialog.onhide = delete_dialog.callback;
+ delete_dialog.hide();
+
+ //refreshing node
+ pscript.load_child_nodes();
+ }
+ $c_obj(sdt,'delete',docstring(args),callback1);
+ }
+
+ delete_dialog.n_btn = $a($i('delete_record'),'button','button');
+ delete_dialog.n_btn.innerHTML = 'Cancel';
+
+ delete_dialog.n_btn.onclick = function(){
+ delete_dialog.widgets['Response'].innerHTML = '';
+ delete_dialog.onhide = '';
+ delete_dialog.hide();
+ }
+
+ delete_dialog.widgets['Message'].innerHTML = 'Note: All data will be deleted permanantly. Do you want to continue?';
+ pscript.delete_dialog = delete_dialog;
+ }
+ //if(!delete_dialog.display) delete_dialog.show();
+ pscript.delete_dialog.show();
+ pscript.delete_dialog.widgets['Response'].innerHTML = '';
+ pscript.delete_dialog.sdt = sdt; pscript.delete_dialog.dt=dt; pscript.delete_dialog.dn=dn; pscript.delete_dialog.callback = callback;
+}
+
+pscript.remove_child_nodes = function(parent){
+ var len = parent.childNodes.length;
+ if(len){
+ for(l=0; l<len; l++){
+ var c = parent.childNodes[0];
+ parent.removeChild(c);
+ }
+ }
+}
+
+pscript.load_child_nodes = function(){
+ if(pscript.f_cur_parent){
+ pscript.f_cur_parent.clear_child_nodes();
+ pscript.f_cur_parent.expand();
+ pscript.f_cur_parent.select();
+ }
+ else{ pscript.fb_refresh(); }
+}
\ No newline at end of file
diff --git a/tools/page/file_browser/file_browser.txt b/tools/page/file_browser/file_browser.txt
new file mode 100644
index 0000000..fa4f4a1
--- /dev/null
+++ b/tools/page/file_browser/file_browser.txt
@@ -0,0 +1,194 @@
+[
+ {
+ 'content': None,
+ 'creation': '2010-11-30 17:25:41',
+ 'docstatus': 0,
+ 'doctype': 'Page',
+ 'icon': '',
+ 'idx': None,
+ 'menu_index': None,
+ 'modified': '2010-09-25 00:00:00',
+ 'modified_by': 'Administrator',
+ 'module': 'Tools',
+ 'name': 'File Browser',
+ 'owner': 'Administrator',
+ 'page_name': 'File Browser',
+ 'parent': None,
+ 'parent_node': None,
+ 'parentfield': None,
+ 'parenttype': None,
+ 'script': None,
+ 'show_in_menu': 1,
+ 'standard': 'Yes',
+ 'static_content': '',
+ 'style': ''
+ },
+ {
+ 'creation': '2010-11-30 17:25:41',
+ 'docstatus': 0,
+ 'doctype': 'Page Role',
+ 'idx': 1,
+ 'modified': '2010-11-30 17:25:41',
+ 'modified_by': 'Administrator',
+ 'name': 'PR000031',
+ 'owner': 'Administrator',
+ 'parent': 'File Browser',
+ 'parentfield': 'roles',
+ 'parenttype': 'Page',
+ 'role': 'Administrator'
+ },
+ {
+ 'creation': '2010-11-30 17:25:41',
+ 'docstatus': 0,
+ 'doctype': 'Page Role',
+ 'idx': 2,
+ 'modified': '2010-11-30 17:25:41',
+ 'modified_by': 'Administrator',
+ 'name': 'PR000032',
+ 'owner': 'saumil@webnotestech.com',
+ 'parent': 'File Browser',
+ 'parentfield': 'roles',
+ 'parenttype': 'Page',
+ 'role': 'Sales User'
+ },
+ {
+ 'creation': '2010-11-30 17:25:41',
+ 'docstatus': 0,
+ 'doctype': 'Page Role',
+ 'idx': 3,
+ 'modified': '2010-11-30 17:25:41',
+ 'modified_by': 'Administrator',
+ 'name': 'PR000033',
+ 'owner': 'saumil@webnotestech.com',
+ 'parent': 'File Browser',
+ 'parentfield': 'roles',
+ 'parenttype': 'Page',
+ 'role': 'Sales Manager'
+ },
+ {
+ 'creation': '2010-11-30 17:25:41',
+ 'docstatus': 0,
+ 'doctype': 'Page Role',
+ 'idx': 4,
+ 'modified': '2010-11-30 17:25:41',
+ 'modified_by': 'Administrator',
+ 'name': 'PR000034',
+ 'owner': 'saumil@webnotestech.com',
+ 'parent': 'File Browser',
+ 'parentfield': 'roles',
+ 'parenttype': 'Page',
+ 'role': 'System Manager'
+ },
+ {
+ 'creation': '2010-11-30 17:25:41',
+ 'docstatus': 0,
+ 'doctype': 'Page Role',
+ 'idx': 5,
+ 'modified': '2010-11-30 17:25:41',
+ 'modified_by': 'Administrator',
+ 'name': 'PR000035',
+ 'owner': 'saumil@webnotestech.com',
+ 'parent': 'File Browser',
+ 'parentfield': 'roles',
+ 'parenttype': 'Page',
+ 'role': 'Purchase User'
+ },
+ {
+ 'creation': '2010-11-30 17:25:41',
+ 'docstatus': 0,
+ 'doctype': 'Page Role',
+ 'idx': 6,
+ 'modified': '2010-11-30 17:25:41',
+ 'modified_by': 'Administrator',
+ 'name': 'PR000036',
+ 'owner': 'saumil@webnotestech.com',
+ 'parent': 'File Browser',
+ 'parentfield': 'roles',
+ 'parenttype': 'Page',
+ 'role': 'Purchase Manager'
+ },
+ {
+ 'creation': '2010-11-30 17:25:41',
+ 'docstatus': 0,
+ 'doctype': 'Page Role',
+ 'idx': 7,
+ 'modified': '2010-11-30 17:25:41',
+ 'modified_by': 'Administrator',
+ 'name': 'PR000037',
+ 'owner': 'saumil@webnotestech.com',
+ 'parent': 'File Browser',
+ 'parentfield': 'roles',
+ 'parenttype': 'Page',
+ 'role': 'Accounts User'
+ },
+ {
+ 'creation': '2010-11-30 17:25:41',
+ 'docstatus': 0,
+ 'doctype': 'Page Role',
+ 'idx': 8,
+ 'modified': '2010-11-30 17:25:41',
+ 'modified_by': 'Administrator',
+ 'name': 'PR000038',
+ 'owner': 'saumil@webnotestech.com',
+ 'parent': 'File Browser',
+ 'parentfield': 'roles',
+ 'parenttype': 'Page',
+ 'role': 'Accounts Manager'
+ },
+ {
+ 'creation': '2010-11-30 17:25:41',
+ 'docstatus': 0,
+ 'doctype': 'Page Role',
+ 'idx': 9,
+ 'modified': '2010-11-30 17:25:41',
+ 'modified_by': 'Administrator',
+ 'name': 'PR000039',
+ 'owner': 'saumil@webnotestech.com',
+ 'parent': 'File Browser',
+ 'parentfield': 'roles',
+ 'parenttype': 'Page',
+ 'role': 'Production User'
+ },
+ {
+ 'creation': '2010-11-30 17:25:41',
+ 'docstatus': 0,
+ 'doctype': 'Page Role',
+ 'idx': 10,
+ 'modified': '2010-11-30 17:25:41',
+ 'modified_by': 'Administrator',
+ 'name': 'PR000040',
+ 'owner': 'saumil@webnotestech.com',
+ 'parent': 'File Browser',
+ 'parentfield': 'roles',
+ 'parenttype': 'Page',
+ 'role': 'Production Manager'
+ },
+ {
+ 'creation': '2010-11-30 17:25:41',
+ 'docstatus': 0,
+ 'doctype': 'Page Role',
+ 'idx': 11,
+ 'modified': '2010-11-30 17:25:41',
+ 'modified_by': 'Administrator',
+ 'name': 'PR000041',
+ 'owner': 'saumil@webnotestech.com',
+ 'parent': 'File Browser',
+ 'parentfield': 'roles',
+ 'parenttype': 'Page',
+ 'role': 'Material User'
+ },
+ {
+ 'creation': '2010-11-30 17:25:41',
+ 'docstatus': 0,
+ 'doctype': 'Page Role',
+ 'idx': 12,
+ 'modified': '2010-11-30 17:25:41',
+ 'modified_by': 'Administrator',
+ 'name': 'PR000042',
+ 'owner': 'Administrator',
+ 'parent': 'File Browser',
+ 'parentfield': 'roles',
+ 'parenttype': 'Page',
+ 'role': 'Customer'
+ }
+]
\ No newline at end of file
diff --git a/tools/page/messages/__init__.py b/tools/page/messages/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tools/page/messages/__init__.py
diff --git a/tools/page/messages/messages.html b/tools/page/messages/messages.html
new file mode 100644
index 0000000..ded3393
--- /dev/null
+++ b/tools/page/messages/messages.html
@@ -0,0 +1,2 @@
+<div id="message_header" style="margin-bottom: 8px"></div>
+<div id="inbox_tabs"></div>
\ No newline at end of file
diff --git a/tools/page/messages/messages.js b/tools/page/messages/messages.js
new file mode 100644
index 0000000..258961d
--- /dev/null
+++ b/tools/page/messages/messages.js
@@ -0,0 +1,929 @@
+pscript.onload_Messages = function() {
+ var p = new PageHeader($i('message_header'),'Messages');
+ pscript.msg_struct = new Message();
+}
+
+pscript.onshow_Messages = function() {
+ pscript.msg_struct.show_inbox();
+}
+
+function Message(){
+ if(!this.mytabs) this.make_body();
+}
+
+Message.prototype.make_body = function() {
+ var me = this;
+ this.mytabs = new TabbedPage($i('inbox_tabs'));
+ $y(this.mytabs.body_area, {padding:'16px'})
+
+ me.make_inbox();
+ me.make_compose();
+ me.make_sent();
+
+ this.mytabs.tabs['Inbox'].show();
+}
+
+Message.prototype.make_inbox = function() {
+ var me = this;
+
+ //inbox tab
+ me.mytabs.add_tab('Inbox', function() {
+ me.inbox_lst.generate_unread_lst();
+ me.inbox_lst.msg_li.run();
+ me.cur_inbox_list = me.inbox_lst.msg_li; // for refresh
+ });
+
+ if(!this.inbox_lst) this.inbox_lst = new MessageList(me.mytabs.tabs['Inbox'].tab_body, 'inbox msg');
+ this.inbox_lst.msg_li.get_query = function() {
+ //me.checked_msg_lst = [];
+ me.all_msg = {};
+ this.query = repl("select distinct t1.name, t1.last_updated_on, t1.last_updated_by, t1.subject, t3.first_name, t3.file_list, t1.message_date, t1.owner, t1.message, t1.previous_updated_by from `tabMail` t1, `tabMail Participant Details` t2, `tabProfile` t3 where t1.is_main_thread='Yes' and t2.participant_name='%(user)s' and (t2.delete_status is NULL or t2.delete_status = 'No') and t1.name = t2.parent and ((t1.last_updated_by = t3.name and t1.last_updated_by!='%(user)s') or (t1.previous_updated_by = t3.name and t1.previous_updated_by!='%(user)s')) order by t1.modified desc", {'user':user});
+
+ this.query_max = repl("select distinct count(t1.name) from `tabMail` t1, `tabMail Participant Details` t2, `tabProfile` t3 where t1.is_main_thread='Yes' and t2.participant_name='%(user)s' and (t2.delete_status is NULL or t2.delete_status = 'No') and t1.name = t2.parent and ((t1.last_updated_by = t3.name and t1.last_updated_by!='%(user)s') or (t1.previous_updated_by = t3.name and t1.previous_updated_by!='%(user)s')) order by t1.modified desc", {'user':user});
+ }
+
+ this.inbox_lst.generate_unread_lst();
+ this.inbox_lst.msg_li.run();
+ this.inbox_lst.msg_li.onrun = function(){ me.inbox_lst.show_if_no_msg(me.inbox_lst.msg_li); }
+}
+
+Message.prototype.make_compose = function() {
+ var me = this;
+
+ me.mytabs.add_tab('Compose', function() {
+ if(!pscript.compose_msg_obj){
+ pscript.compose_msg_obj = new MessageThread(me.mytabs.tabs['Compose'].tab_body, me.mytabs.tabs['Inbox'], me.inbox_lst.lst_wrapper, 'My Inbox');
+ //pscript.compose_msg_obj.show_msg(0, me.mytabs.tabs['Compose'].tab_body, me.mytabs.tabs['Inbox'], me.inbox_lst.lst_wrapper, 'My Inbox', me.mytabs.tabs['Sent'], me.sent_lst.lst_wrapper);
+ }
+ pscript.compose_msg_obj.show_msg(0, me.mytabs.tabs['Compose'].tab_body, me.mytabs.tabs['Inbox'], me.inbox_lst.lst_wrapper, 'My Inbox', me.mytabs.tabs['Sent'], me.sent_lst.lst_wrapper);
+
+ this.cur_inbox_list = null;
+ });
+}
+
+Message.prototype.make_sent = function() {
+ var me = this;
+
+ // sent msg tab
+ me.mytabs.add_tab('Sent', function() {
+ me.sent_lst.msg_li.run();
+ me.cur_inbox_list = me.sent_lst.msg_li; // for refresh
+ });
+
+ if(!this.sent_lst) this.sent_lst = new MessageList(me.mytabs.tabs['Sent'].tab_body, 'sent msg');
+ this.sent_lst.msg_li.get_query = function() {
+ //me.checked_msg_lst = [];
+ me.all_msg = {};
+
+ this.query = repl("select distinct t1.name, t1.last_updated_on, t1.last_updated_by, t1.subject, t3.first_name, t3.file_list, t1.message_date, t1.owner, t1.message from `tabMail` t1, `tabProfile` t3, `tabMail Participant Details` t2 where t1.is_main_thread='Yes' and t1.last_updated_by='%(user)s' and t1.last_updated_by = t3.name and t2.participant_name = '%(user)s' and (t2.delete_status is NULL or t2.delete_status = 'No') and t2.parent = t1.name order by t1.modified desc", {'user':user});
+ this.query_max = repl("select distinct count(t1.name) from `tabMail` t1, `tabProfile` t3, `tabMail Participant Details` t2 where t1.is_main_thread='Yes' and t1.last_updated_by='%(user)s' and t1.last_updated_by = t3.name and t2.participant_name = '%(user)s' and (t2.delete_status is NULL or t2.delete_status = 'No') and t2.parent = t1.name order by t1.modified desc", {'user':user});
+ }
+ this.sent_lst.msg_li.run();
+ this.sent_lst.msg_li.onrun = function(){ me.sent_lst.show_if_no_msg(me.sent_lst.msg_li); }
+}
+
+Message.prototype.show_inbox = function(){
+ var me = this;
+ if(me.inbox_lst){
+ me.inbox_lst.msg_li.run();
+ }
+ me.mytabs.tabs['Inbox'].show();
+}
+
+MessageList = function(parent_tab, req_frm) {
+ this.checked_msg_lst = [];
+ this.unread_msg_lst = [];
+ this.all_msg = {};
+ this.parent_tab = parent_tab;
+ this.req_frm = req_frm;
+ this.make();
+}
+
+MessageList.prototype.make = function(){
+ var me = this;
+
+ this.lst_wrapper = $a(me.parent_tab, 'div');
+
+ //toolbar
+ this.toolbar_area = $a(this.lst_wrapper, 'div', '', {paddingTop:'12px'});
+ this.create_toolbar();
+
+ //no inbox msg div
+ this.no_lst_wrapper = $a(me.parent_tab, 'div', '', {padding:'8px',backgroundColor:'#FFE4AA'});
+ $dh(this.no_lst_wrapper);
+
+ //view inbox msg div
+ this.view_msg_wrapper = $a(me.parent_tab, 'div');
+
+ this.msg_li = new Listing("Recent Messages",1);
+ this.msg_li.colwidths = ['90%'];
+ this.msg_li.opts.no_border = 1;
+ this.msg_li.opts.show_empty_tab = 0;
+ this.msg_li.opts.no_border = 1;
+
+ this.msg_li.show_cell = function(cell,ri,ci,d) {
+ if(ri % 2)$y(cell,{backgroundColor:'#E1E3DE'});
+ if(ci ==0){
+ this.msg_lst = new MessagePreview(cell, me.req_frm, d[ri][0], d[ri][1], d[ri][2], d[ri][3], d[ri][4], d[ri][5], d[ri][6], d[ri][7], d[ri][8], d[ri][9], me.lst_wrapper, me.view_msg_wrapper, me.unread_msg_lst, me.all_msg);
+ }
+ }
+ this.msg_li.make(this.lst_wrapper);
+ $dh(this.msg_li.btn_area);
+}
+
+MessageList.prototype.create_toolbar = function(){
+ var me = this;
+
+ this.toolbar_tbl = make_table(me.toolbar_area, 1, 2, '100%', ['85%', '15%']);
+
+ this.select_all_lnk = $a($td(this.toolbar_tbl, 0, 0), 'span', 'link_type');
+ this.select_all_lnk.innerHTML = 'Select All';
+ $dh(this.select_all_lnk);
+
+ this.unselect_all_lnk = $a($td(this.toolbar_tbl, 0, 0), 'span', 'link_type');
+ this.unselect_all_lnk.innerHTML = 'Unselect All';
+ $dh(this.unselect_all_lnk);
+
+ this.select_all_lnk.onclick = function(){
+ $ds(me.unselect_all_lnk);
+ $dh(me.select_all_lnk);
+ for(m in me.all_msg){
+ me.all_msg[m].checked = true;
+ }
+ }
+
+ this.unselect_all_lnk.onclick = function(){
+ $ds(me.select_all_lnk);
+ $dh(me.unselect_all_lnk);
+ for(m in me.all_msg){
+ me.all_msg[m].checked = false;
+ }
+ }
+
+ this.delete_selected_btn = $a($td(this.toolbar_tbl, 0, 1), 'button', 'button', {align:'right'});
+ this.delete_selected_btn.innerHTML = 'Delete Selected';
+ $dh(this.delete_selected_btn);
+ this.delete_selected_btn.onclick = function(){
+ me.checked_msg_lst = [];
+ for(m in me.all_msg){
+ if(me.all_msg[m].checked == true)
+ me.checked_msg_lst.push(m);
+ }
+ me.delete_selected();
+ }
+}
+
+MessageList.prototype.show_if_no_msg = function(lst_data){
+ var me = this;
+ $dh(me.view_msg_wrapper);
+
+ if(!lst_data.has_data()){
+ $ds(me.no_lst_wrapper);
+ $dh(me.lst_wrapper);
+ if(me.req_frm == 'inbox msg'){
+ me.no_lst_wrapper.innerHTML = "You have no messages in your Inbox.";
+ }
+ else if(me.req_frm == 'sent msg'){
+ me.no_lst_wrapper.innerHTML = "You have no messages in your Sent messages list.";
+ }
+ } else {
+ $dh(me.no_lst_wrapper);
+ $ds(me.lst_wrapper);
+ $dh(me.no_lst_wrapper);
+ $ds(me.lst_wrapper);
+ $dh(this.unselect_all_lnk);
+ $ds(this.select_all_lnk);
+ $ds(this.delete_selected_btn);
+ }
+}
+
+MessageList.prototype.generate_unread_lst = function(){
+ var me = this;
+
+ var msg_callback = function(r, rt){
+ if(r.message.ur_lst){
+ me.unread_msg_lst = r.message.ur_lst;
+ }
+ }
+ $c('runserverobj', {doctype:'Message Control',method:'get_unread_msg_lst',arg:user}, msg_callback);
+}
+
+MessageList.prototype.delete_selected = function(){
+ var me = this;
+
+ if(me.checked_msg_lst.length >= 1) me.msg_li.msg_lst.delete_msg(me.checked_msg_lst);
+ else msgprint("error:Please select the message to delete");
+}
+
+function MessagePreview(parent, req_frm, msg_id, last_updated_on, last_updated_by, subject, first_name, profile_pic, msg_date, msg_owner, message, previous_updated_by, lst_wrapper, view_msg_wrapper, unread_msg_lst, all_msg_dict) {
+ this.create_structure(parent);
+
+ if(req_frm) this.req_frm = req_frm;
+ this.msg_id = msg_id;
+ this.subject = subject;
+ this.message = message;
+ this.msg_date = msg_date;
+ this.msg_owner = msg_owner;
+ this.first_name = first_name;
+ this.lst_wrapper = lst_wrapper;
+ this.view_msg_wrapper = view_msg_wrapper;
+ if(profile_pic) this.profile_pic = profile_pic;
+ if(last_updated_on) this.last_updated_on = last_updated_on;
+ if(last_updated_by) this.last_updated_by = last_updated_by;
+ if(previous_updated_by) this.previous_updated_by = previous_updated_by;
+ this.unread_msg_lst = unread_msg_lst;
+ this.all_msg = all_msg_dict;
+
+ this.show_msg_sender();
+ this.show_msg_subject();
+ this.show_delete_lnk();
+}
+
+MessagePreview.prototype.create_structure = function(parent){
+ this.wrapper = $a(parent,'div');
+ this.t = make_table(this.wrapper, 1, 4, '100%', ['5%','10%','80%','5%']);
+}
+
+MessagePreview.prototype.show_msg_sender = function(){
+ var me = this;
+
+ // checkbox
+ var chk_box = $a($td(this.t, 0, 0),'div');
+ if(isIE) {
+ chk_box.innerHTML = '<input type="checkbox" style="border: 0px">'; // IE fix
+ this.inp = chk_box.childNodes[0];
+ } else {
+ this.inp = $a(chk_box, 'input');
+ this.inp.type = 'checkbox';
+ }
+
+ this.inp.onclick = function() {
+ for(m in me.all_msg){
+ if(m == me.msg_id)
+ me.all_msg[m].checked = me.inp.checked;
+ }
+ }
+
+ me.all_msg[me.msg_id] = this.inp;
+
+ //sender or receiver
+ // photo
+ if(this.profile_pic) {
+ var img = $a($td(this.t, 0, 1),'img');
+ var img_src = this.profile_pic.split(NEWLINE)[0].split(',')[0]
+ img.src = repl('cgi-bin/getfile.cgi?name=%(fn)s&thumbnail=32',{fn:img_src})
+ }
+ //name
+ var div = $a($td(this.t, 0, 1),'div');
+ div.innerHTML = this.first_name;
+}
+
+MessagePreview.prototype.show_msg_subject = function() {
+ var me = this;
+ // message
+ var div1 = $a($td(this.t, 0, 2),'div', '', {paddingBottom:'4px'});
+ var sp = $a(div1,'span','link_type', {fontSize:'12px'});
+ sp.innerHTML = 'Sub : ' +me.subject;
+
+ var div = $a($td(this.t, 0, 2),'div', 'comment',{paddingBottom:'8px'});
+ div.innerHTML = 'created by: ' + me.msg_owner +' | created on: ' + dateutil.str_to_user(me.msg_date)+ ' | last updated on: ' + dateutil.str_to_user(me.last_updated_on);
+
+ if (me.req_frm == 'inbox msg' && inList(me.unread_msg_lst, me.msg_id)) {
+ $y(sp,{fontWeight:'bold',color:'Black'});
+ $y(div,{fontWeight:'bold',color:'Black'});
+ }
+
+ sp.style.cursor = 'pointer';
+ sp.msg_id = me.msg_id; sp.req_frm = me.req_frm;
+
+ sp.onclick = function() {
+ $dh(me.lst_wrapper);
+ if(this.req_frm == 'inbox msg'){
+ if(!pscript.inbox_msg_obj){
+ pscript.inbox_msg_obj = new MessageThread(me.view_msg_wrapper, pscript.msg_struct.mytabs.tabs['Inbox'], me.lst_wrapper, 'My Inbox');
+ }
+ pscript.inbox_msg_obj.show_msg(this.msg_id, me.view_msg_wrapper, pscript.msg_struct.mytabs.tabs['Inbox'], me.lst_wrapper, 'My Inbox', pscript.msg_struct.mytabs.tabs['Sent'], me.lst_wrapper);
+
+ //mark for already read
+ if (this.req_frm == 'inbox msg' && inList(me.unread_msg_lst,this.msg_id)) {
+ me.mark_as_read(this.msg_id);
+ }
+ }
+ else if(this.req_frm == 'sent msg'){
+ if(!pscript.sent_msg_obj){
+ pscript.sent_msg_obj = new MessageThread(me.view_msg_wrapper, pscript.msg_struct.mytabs.tabs['Sent'], me.lst_wrapper, 'My Inbox');
+ }
+ pscript.sent_msg_obj.show_msg(this.msg_id, me.view_msg_wrapper, pscript.msg_struct.mytabs.tabs['Sent'], me.lst_wrapper, 'My Inbox', pscript.msg_struct.mytabs.tabs['Sent'], me.lst_wrapper);
+ }
+ }
+}
+
+MessagePreview.prototype.mark_as_read = function(msg_id){
+ this.msg_id = msg_id;
+ var me = this;
+
+ args = {'user' : user, 'msg':this.msg_id,'read':'Yes'}
+ $c_obj('Message Control','read_unread_message',docstring(args),function(r,rt){
+ me.remove_element(me.unread_msg_lst, me.msg_id);
+ });
+}
+
+MessagePreview.prototype.delete_msg = function(msg_nm_lst){
+ this.msg_nm_lst = msg_nm_lst;
+ var me = this;
+ var delete_msg_dialog;
+
+ set_delete_msg_dialog = function() {
+ delete_msg_dialog = new Dialog(400, 200, 'Delete Message');
+ delete_msg_dialog.make_body([
+ ['HTML', 'Message', '<div class = "comment">Are you sure, you want to delete message(s) ?</div>'],
+ ['HTML', 'Response', '<div class = "comment" id="delete_msg_dialog_response"></div>'],
+ ['HTML', 'Delete Msg', '<div></div>']
+ ]);
+
+ var delete_msg_btn1 = $a($i(delete_msg_dialog.widgets['Delete Msg']), 'button', 'button');
+ delete_msg_btn1.innerHTML = 'Yes';
+ delete_msg_btn1.onclick = function(){ delete_msg_dialog.add(); }
+
+ var delete_msg_btn2 = $a($i(delete_msg_dialog.widgets['Delete Msg']), 'button', 'button');
+ delete_msg_btn2.innerHTML = 'No';
+ $y(delete_msg_btn2,{marginLeft:'4px'});
+ delete_msg_btn2.onclick = function(){ delete_msg_dialog.hide();}
+
+ delete_msg_dialog.onshow = function() {
+ $i('delete_msg_dialog_response').innerHTML = '';
+ }
+
+ delete_msg_dialog.add = function() {
+ // sending...
+ $i('delete_msg_dialog_response').innerHTML = 'Processing...';
+ var m_arg = user+ '~~' + this.msg_nm_lst;
+
+ var call_back = function(r,rt) {
+ if(r.message == 'true'){
+ $i('delete_msg_dialog_response').innerHTML = 'Message Deleted';
+ delete_msg_dialog.hide();
+
+ for(m=0; m<me.msg_nm_lst.length; m++){
+ if(inList(me.unread_msg_lst, me.msg_nm_lst[m]))
+ me.remove_element(me.unread_msg_lst, me.msg_nm_lst[m]);
+ }
+ pscript.msg_struct.inbox_lst.msg_li.run();
+ pscript.msg_struct.sent_lst.msg_li.run();
+ }
+ }
+ $c('runserverobj', {doctype:'Message Control',method:'delete_message',arg:m_arg}, call_back);
+ }
+ }
+
+ if(!delete_msg_dialog){
+ set_delete_msg_dialog();
+ }
+ delete_msg_dialog.msg_nm_lst = this.msg_nm_lst;
+ delete_msg_dialog.show();
+}
+
+MessagePreview.prototype.remove_element = function(arrayName, arrayElement){
+ for(var i=0; i<arrayName.length;i++ )
+ {
+ if(arrayName[i]==arrayElement)
+ arrayName.splice(i,1);
+ }
+}
+
+MessagePreview.prototype.show_delete_lnk = function() {
+ var me = this;
+ var div = $a($td(this.t, 0, 3), 'span', 'link_type');
+ div.innerHTML = 'Delete';
+ div.msg_id = me.msg_id;
+
+ div.onclick = function() {
+ me.delete_msg(me.msg_id);
+ }
+}
+
+MessagePart = function(parent){
+ var me = this;
+
+ this.parent = parent;
+ this.inputs = {};
+
+ me.make_header();
+ me.make_reply();
+ me.make_post();
+}
+
+MessagePart.prototype.make = function(label, ele, comment){
+ var me = this;
+
+ var div = $a(this.parent,'div','',{marginBottom:'12px'});
+ var t = make_table(div,2,1,'70%',['100%']);
+
+ if( ele == 'button'){
+ var element = $a($td(t,0,0), 'button');
+ element.innerHTML = label;
+ }
+ else {
+ var element = $a($td(t,1,0),ele);
+
+ // large fonts for inputs
+ if(in_list(['input','textarea'],ele.toLowerCase())) {
+ $y(element,{fontSize:'14px', width:'100%'})
+ }
+ $td(t,0,0).innerHTML = label;
+ }
+
+ if(comment) {
+ var div2 = $a(div,'div','',{fontSize:'11px', color:'#888', marginTop:'2px'});
+ div2.innerHTML = comment;
+ }
+
+ element.wrapper = div;
+ if(label) me.inputs[label] = element;
+ return element;
+}
+
+MessagePart.prototype.make_header = function(){
+ var me = this;
+
+ this.back_link_div = $a(me.make('','div'),'span', 'link_type', {paddingTop:'12px'});
+ this.back_link_div.innerHTML = 'Back to List';
+
+ me.make('To','textarea','Enter Email Ids separated by commas (,)');
+ $y(me.inputs['To'],{overflow :'auto', height : '50px'});
+ me.make('Subject','input');
+}
+
+MessagePart.prototype.make_reply = function(){
+ var me = this;
+ this.inputs.Thread = $a(this.parent, 'div', '', {margin:'16px 0px'})
+}
+
+MessagePart.prototype.make_post = function(){
+ var me = this;
+
+ me.make('Message','textarea');
+ $y(me.inputs['Message'],{height:'240px'});
+
+ // send + cancel
+ var d = $a(this.parent, 'div');
+ me.inputs.Send = $btn(d, 'Send');
+ me.inputs.Reply = $a(d, 'Reply')
+}
+
+MessagePart.prototype.add_header_values = function(to_list, subject){
+ var me = this;
+
+ //thread_participants
+ me.inputs['To'].value = to_list.join(',');
+ me.inputs['To'].disabled = true;
+
+ // subject
+ me.inputs['Subject'].value = subject;
+ me.inputs['Subject'].disabled = true;
+}
+
+MessagePart.prototype.add_reply_thread = function(thread){
+ var me = this;
+ // prev messages
+ var t = me.inputs['Thread'];
+ t.innerHTML = ''; // clear previous threads
+
+ var w = $a(t,'div','',{width:'70%'});
+ var tab = make_table(w,thread.length,2,'100%',['20%','80%'], {padding:'8px 0px', borderBottom:'1px solid #AAA'});
+
+ for(i=0;i<thread.length;i++) {
+ // ---- photo ----
+ if(thread[i][6]) {
+ var img = $a($td(tab,i,0),'img');
+ var img_src = thread[i][6].split(NEWLINE)[0].split(',')[0];
+ img.src = repl('cgi-bin/getfile.cgi?name=%(fn)s&thumbnail=32',{fn:img_src});
+ }
+
+ // ---- sender name ----
+ var d = $a($td(tab,i,0),'div','',{fontSize:'11px'});
+ d.innerHTML = thread[i][5];
+
+ //----- date ----
+ var d = $a($td(tab,i,1),'div', 'comment', {marginLeft:'8px', color:'#888', fontSize:'11px'});
+ d.innerHTML = dateutil.str_to_user(thread[i][3]);
+
+ //------ message ------
+ var d = $a($td(tab,i,1),'div', 'comment', {fontSize:'14px', marginLeft:'8px'});
+ d.innerHTML = replace_newlines(thread[i][1]);
+ $y($td(tab,i,1), {paddingBottom: '8px'});
+ }
+}
+
+//++++++++++++++++++++++++ Message ++++++++++++++++++++++++
+
+MessageThread = function(parent, view_list_tab, view_list_div, req_frm) {
+ var me = this;
+ this.wrapper = $a(parent,'div');
+ if(!this.msg_parts) this.make(view_list_tab, view_list_div, req_frm);
+}
+
+
+MessageThread.prototype.add_autosuggest = function() {
+ var me = this;
+
+ // ---- add auto suggest ----
+ var opts = { script: '', json: true, maxresults: 10, timeout: 10000, delay:250, maxentries:500, cache:false};
+
+ var as = new AutoSuggest(me.msg_parts.inputs['To'], opts);
+ as.custom_select = function(txt, sel) {
+ // ---- add to the last comma ----
+
+ var r = '';
+ var tl = txt.split(',');
+ for(var i=0;i<tl.length-1;i++) r=r+tl[i]+',';
+ r = r+(r?' ':'')+sel+',';
+ if(r[r.length-1]==NEWLINE) { r=substr(0,r.length-1);}
+ return r;
+ }
+
+ // ---- override server call ----
+ as.doAjaxRequest = function(txt) {
+ var pointer = as; var q = '';
+
+ // ---- get last few letters typed ----
+ var last_txt = txt.split(',');
+ last_txt = last_txt[last_txt.length-1];
+
+ // ---- show options ----
+ var call_back = function(r,rt) {
+ as.aSug = [];
+ var jsondata = r.message;
+ for (var i=0;i<jsondata.results.length;i++) {
+ as.aSug.push({'id':jsondata.results[i].id, 'value':jsondata.results[i].value, 'info':jsondata.results[i].info});
+ }
+ as.idAs = "as_for_to_message";
+
+ //old create list
+ as.createList(as.aSug);
+ }
+
+ $c_obj('Message Control', 'get_to_list', (last_txt ? last_txt : '%'), call_back);
+ return;
+ }
+}
+
+MessageThread.prototype.make = function(view_list_tab, view_list_div, req_frm) {
+ var me = this;
+
+ me.view_list_tab = view_list_tab;
+ me.view_list_div = view_list_div;
+ me.req_frm = req_frm;
+
+ this.msg_parts = new MessagePart(me.wrapper);
+
+ this.msg_parts.back_link_div.onclick = function() {
+ me.hide();
+
+ if(me.in_compose) {
+ if(me.req_frm == 'My Inbox') { me.view_list_tab.show(); $ds(me.view_list_div); }
+ }
+ }
+
+ // autosuggest
+ me.add_autosuggest();
+}
+
+MessageThread.prototype.set_inbox_editor = function(editor) {
+ pscript.inbox_text_editor_set = 1;
+}
+
+MessageThread.prototype.view_existing_msg = function(args){
+ var me = this;
+
+ $c_obj('Message Control', 'get_thread_details', docstring(args),
+ function(r, rt){
+ var tl = r.message.tl;
+ var to_list = r.message.to_list;
+
+ //to and subject
+ me.msg_parts.add_header_values(to_list, tl[0][0]);
+
+ //reply thread
+ me.msg_parts.add_reply_thread(tl);
+
+ //post area
+ if(me.inbox_editor && pscript.inbox_text_editor_set == 1){
+ me.inbox_editor.editor.setContent('');
+ }
+ else{
+ me.msg_parts.inputs['Message'].value = '';
+ }
+ me.show_as(true);
+ }
+ );
+}
+
+MessageThread.prototype.view_blank_form = function(){
+ var me = this;
+
+ $ds(me.msg_parts.inputs['To'].wrapper);
+
+ me.msg_parts.inputs['To'].disabled = false;
+ me.msg_parts.inputs['To'].value = '';
+
+ me.msg_parts.inputs['Subject'].disabled = false;
+ me.msg_parts.inputs['Subject'].value = '';
+
+ me.msg_parts.inputs['Thread'].innerHTML = '';
+
+ if(me.inbox_editor && pscript.inbox_text_editor_set == 1){
+ me.inbox_editor.editor.setContent('');
+ }
+ else{
+ me.msg_parts.inputs['Message'].value = '';
+ }
+ me.show_as(false);
+}
+
+// msg_id = mesage id,
+// parent = div/tab from where msg will be shown,
+// view_list_tab = name of tab in which list will be viewed,
+// view_list_div = name of div in which list will be viewed,
+// req_frm = my inbox / group / event,
+// show_on_send_tab = tab to be viewed on sending/replying to msg,
+// show_on_send_div = div to be viewed on sending/replying to msg,
+// receiver_lst = list of msg receiver
+
+MessageThread.prototype.show_msg = function(msg_id, parent, view_list_tab, view_list_div, req_frm, show_on_send_tab, show_on_send_div, receiver_lst) {
+ var me = this;
+
+ // set tinymce editor
+ if(!me.inbox_editor) {
+ pscript.inbox_text_editor_set = 0;
+ var theme_adv_btn1 ="fontselect,fontsizeselect,formatselect,indicime,indicimehelp,emotions";
+ var theme_adv_btn2 ="bold,italic,underline,|,undo,redo,|,code,forecolor,backcolor,link,unlink,hr,|,sub,sup,|,charmap";
+ var theme_adv_btn3 = "";
+
+ me.inbox_editor = new TextAreaEditor(me.msg_parts.inputs["Message"], null, me.set_inbox_editor, theme_adv_btn1, theme_adv_btn2, theme_adv_btn3, '300px');
+ }
+
+ me.req_frm = req_frm;
+ me.receiver_lst = receiver_lst;
+ me.parent = parent;
+ me.view_list_tab = view_list_tab;
+ me.view_list_div = view_list_div;
+ me.show_on_send_tab = show_on_send_tab;
+ me.show_on_send_div = show_on_send_div;
+ me.msg_parts.inputs['Send'].btn_click = 0;
+ me.msg_parts.inputs['Reply'].btn_click = 0;
+
+ if(msg_id) {
+ this.cur_message_id = msg_id;
+ var args = {'user_name':user, 'cur_msg_id': this.cur_message_id};
+ me.view_existing_msg(args);
+ }
+ else {
+ this.cur_message_id = null;
+ me.view_blank_form();
+ }
+ $ds(me.parent);
+
+ // reply or send btn
+ me.msg_parts.inputs['Send'].onclick = function(){
+ if(!this.btn_click){
+ this.btn_click = 1;
+ me.send(me.req_frm, me.receiver_lst, me.show_on_send_tab, me.show_on_send_div);
+ }
+ }
+ me.msg_parts.inputs['Reply'].onclick = me.msg_parts.inputs['Send'].onclick;
+}
+
+MessageThread.prototype.hide = function() {
+ var me = this;
+
+ $dh(me.wrapper);
+ $ds(me.view_list_div);
+ me.display = 0;
+}
+
+MessageThread.prototype.show_as = function(reply) {
+ var me = this;
+
+ if(!reply) {
+ $dh(me.msg_parts.inputs['Thread'].wrapper);
+ $dh(me.msg_parts.inputs['Reply']);
+ $ds(me.msg_parts.inputs['Send']);
+ me.in_compose = 1;
+ }
+ else {
+ $ds(me.msg_parts.inputs['Thread'].wrapper);
+ $ds(me.msg_parts.inputs['Reply']);
+ $dh(me.msg_parts.inputs['Send']);
+ $dh(me.view_list_div);
+ me.in_compose = 1;
+ }
+ $ds(me.wrapper);
+ me.display = 1;
+}
+
+MessageThread.prototype.send_msg = function(arg){
+ var me = this;
+ var args = arg;
+
+ var send_call_back = function(r, rt){
+ //var me = this;
+ if(r.message == 'true'){
+ me.msg_parts.inputs['To'].value = '';
+ me.msg_parts.inputs['Subject'].value = '';
+ me.msg_parts.inputs['Thread'].innerHTML = '';
+
+ if(me.inbox_editor && pscript.inbox_text_editor_set == 1){
+ me.inbox_editor.editor.setContent('');
+ }
+ else{
+ me.msg_parts.inputs['Message'].value = '';
+ }
+
+ if(me.req_frm == 'My Inbox'){
+ pscript.msg_struct.sent_lst.msg_li.run();
+ me.show_on_send_tab.show();
+ $ds(me.show_on_send_div);
+ $dh(me.parent);
+ }
+ }
+ }
+
+ if(me.cur_message_id==null){
+ $c_obj('Message Control','send_message',docstring(args), send_call_back);
+ }
+ else{
+ $c_obj('Message Control','send_reply',docstring(args), send_call_back);
+ }
+}
+
+MessageThread.prototype.send = function(req_frm, receiver_lst, show_on_send_tab, show_on_send_div) {
+ var me = this;
+ me.req_frm = req_frm;
+ me.show_on_send_tab = show_on_send_tab;
+ me.show_on_send_div = show_on_send_div;
+ var args = {'user_name':user};
+
+ if(me.inbox_editor && pscript.inbox_text_editor_set == 1){
+ args.message = me.inbox_editor.editor.getContent();
+ }
+ else{
+ args.message = me.msg_parts.inputs['Message'].value;
+ }
+
+ if(me.cur_message_id==null){
+ args.subject = me.msg_parts.inputs['Subject'].value;
+ args.to_list = me.msg_parts.inputs['To'].value;
+ if(!args.to_list) {msgprint('error:Must enter "To:"'); }
+ else if(!args.subject) {msgprint('error:Must enter "Subject"'); }
+ else me.send_msg(args);
+ }
+ else{
+ var subj = me.msg_parts.inputs['Subject'].value;
+ if(!subj.substr(0,3).toLowerCase()=='re:')
+ subj = 'Re: ' + subj;
+ args.subject = subj;
+ args.message_id = me.cur_message_id;
+
+ me.send_msg(args);
+ }
+}
+
+MessageThread.prototype.delete_msg = function(req_frm, parent, view_list_tab, view_list_div) {
+ var me = this;
+
+ var msg_lst = [];
+ var delete_message_dialog;
+ me.parent = parent;
+
+ if(me.cur_message_id)
+ msg_lst.push(me.cur_message_id);
+
+ if(msg_lst.length >= 1){
+ function set_delete_message_dialog() {
+ delete_message_dialog = new Dialog(400, 400, 'Delete Message');
+ delete_message_dialog.make_body([
+ ['HTML', 'Message', '<div class = "comment">Are you sure, you want to delete this message ?</div>'],
+ ['HTML', 'Response', '<div class = "comment" id="delete_message_dialog_response"></div>'],
+ ['HTML', 'Delete Message', '<div id="delete_message_btn" style ="height:25px;"></div>']
+ ]);
+
+ var delete_message_btn1 = $a($i('delete_message_btn'), 'button', 'button');
+ delete_message_btn1.innerHTML = 'Yes';
+ delete_message_btn1.onclick = function(){ delete_message_dialog.add();}
+
+ var delete_message_btn2 = $a($i('delete_message_btn'), 'button', 'button');
+ delete_message_btn2.innerHTML = 'No';
+ $y(delete_message_btn2,{marginLeft:'4px'});
+
+ delete_message_btn2.onclick = function(){ delete_message_dialog.hide();}
+
+ delete_message_dialog.onshow = function() {
+ $i('delete_message_dialog_response').innerHTML = '';
+ }
+
+ delete_message_dialog.add = function() {
+ if(this.req_frm == 'My Inbox'){
+ var args = user + '~~' + this.msg_lst;
+ $c_obj('Message Control', 'delete_message', args, function(r, rt){
+ if(r.message == 'true'){
+ me.hide();
+ me.view_list_tab.show();
+ $ds(me.view_list_div);
+ delete_message_dialog.hide();
+ }
+ });
+ }
+ }
+ }
+
+ if(!delete_message_dialog)
+ set_delete_message_dialog();
+ delete_message_dialog.req_frm = req_frm;
+ delete_message_dialog.msg_lst = msg_lst;
+ delete_message_dialog.view_list_tab = view_list_tab;
+ delete_message_dialog.view_list_div = view_list_div;
+ delete_message_dialog.show();
+ }
+}
+
+// ---------------- editor---------------------
+
+var editor_count = 0;
+
+function TextAreaEditor(txt, parent, callback, theme_advanced_btn1, theme_advanced_btn2, theme_advanced_btn3, editor_ht) {
+
+ this.txt = txt;
+ this.parent = parent;
+ this.callback = callback;
+ if(theme_advanced_btn1) this.theme_advanced_btn1 = theme_advanced_btn1;
+ if(theme_advanced_btn2) this.theme_advanced_btn2 = theme_advanced_btn2;
+ if(theme_advanced_btn3) this.theme_advanced_btn3 = theme_advanced_btn3;
+ if(editor_ht) this.editor_ht = editor_ht;
+
+ // load tinyMCE library
+ this.load_tiny_mce_library();
+}
+
+TextAreaEditor.prototype.load_tiny_mce_library = function() {
+
+ var me = this;
+
+ if(!tinymce_loaded) {
+ tinymce_loaded = 1;
+ tinyMCE_GZ.init(
+ {
+ themes : "advanced",
+ plugins : "style,table,inlinepopups,indicime,emotions",
+ languages : "en",
+ disk_cache : true
+ }, function(){ me.setup_text_area() });
+ }
+ else {
+ me.setup_text_area();
+ }
+}
+
+TextAreaEditor.prototype.setup_text_area = function() {
+
+ var me = this;
+ if(!me.txt) {
+ me.txt = $a(me.parent, 'textarea');
+ }
+
+ editor_count++;
+ me.id = 'editor_text_' + editor_count;
+ me.txt.setAttribute('id', me.id);
+
+ tinyMCE.init({
+ theme : "advanced",
+ mode : "exact",
+ elements: me.id,
+ plugins:"table,style,inlinepopups,indicime,emotions",
+ theme_advanced_toolbar_location : "top",
+ theme_advanced_statusbar_location : "bottom",
+ extended_valid_elements: "div[id|dir|class|align|style]",
+
+ // w/h
+ width: '100%',
+ height: me.editor_ht?me.editor_ht:'50px',
+
+ // buttons
+ //theme_advanced_buttons1 :"bold,italic,underline,strikethrough,blockquote,forecolor,backcolor,bullist,numlist,|,undo,redo,|,image,code,indicime,indicimehelp,emotions",
+ theme_advanced_buttons1 : me.theme_advanced_btn1?me.theme_advanced_btn1:"bold,italic,underline,forecolor,backcolor,|,undo,redo,|,link,unlink,indicime,indicimehelp,emotions",
+ theme_advanced_buttons2 : me.theme_advanced_btn2?me.theme_advanced_btn2:"",
+ theme_advanced_buttons3 : me.theme_advanced_btn3?me.theme_advanced_btn3:"",
+
+ // callback function with editor instance.
+ init_instance_callback : "editor_init_callback"
+ });
+
+ editor_init_callback = function(inst) {
+ me.editor = tinyMCE.get(me.id);
+ me.editor.focus();
+
+ if(me.callback){
+ me.callback(me.editor);
+ }
+ }
+}
\ No newline at end of file
diff --git a/tools/page/messages/messages.txt b/tools/page/messages/messages.txt
new file mode 100644
index 0000000..8369afe
--- /dev/null
+++ b/tools/page/messages/messages.txt
@@ -0,0 +1 @@
+[{'creation': '2010-06-07 10:34:37', 'module': 'Tools', 'doctype': 'Page', 'owner': 'Administrator', 'style': None, 'modified_by': 'nabin@webnotestech.com', 'script': None, 'show_in_menu': 1, 'content': None, 'page_name': 'Messages', 'menu_index': None, 'docstatus': 0, 'parent': None, 'standard': 'Yes', 'icon': None, 'name': 'Messages', 'idx': None, 'static_content': None, 'modified': '2010-09-25 00:00:00', 'parenttype': None, 'parent_node': None, 'parentfield': None}, {'modified_by': 'nabin@webnotestech.com', 'name': 'PR000137', 'parent': 'Messages', 'creation': '2010-06-07 10:34:37', 'modified': '2010-09-01 14:56:20', 'doctype': 'Page Role', 'idx': 1, 'parenttype': 'Page', 'role': 'Administrator', 'owner': 'Administrator', 'docstatus': 0, 'parentfield': 'roles'}, {'modified_by': 'nabin@webnotestech.com', 'name': 'PR000138', 'parent': 'Messages', 'creation': '2010-06-07 13:35:43', 'modified': '2010-09-01 14:56:20', 'doctype': 'Page Role', 'idx': 2, 'parenttype': 'Page', 'role': 'All', 'owner': 'Administrator', 'docstatus': 0, 'parentfield': 'roles'}]
\ No newline at end of file
diff --git a/tools/page/messages/messages_static.html b/tools/page/messages/messages_static.html
new file mode 100644
index 0000000..094418b
--- /dev/null
+++ b/tools/page/messages/messages_static.html
@@ -0,0 +1,2 @@
+<div>
+</div>
\ No newline at end of file
diff --git a/tools/page/trash/__init__.py b/tools/page/trash/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tools/page/trash/__init__.py
diff --git a/tools/page/trash/trash.html b/tools/page/trash/trash.html
new file mode 100644
index 0000000..0fdca75
--- /dev/null
+++ b/tools/page/trash/trash.html
@@ -0,0 +1,2 @@
+<div id="trash_header"> </div>
+<div id="trash_div" style="margin: 0px;"> </div>
\ No newline at end of file
diff --git a/tools/page/trash/trash.js b/tools/page/trash/trash.js
new file mode 100644
index 0000000..a1b44d4
--- /dev/null
+++ b/tools/page/trash/trash.js
@@ -0,0 +1,128 @@
+pscript['onload_Trash'] = function() {
+
+ // header and toolbar
+ var h = new PageHeader('trash_header','Trash Bin','Restore the documents that you have trashed')
+
+ if(!pscript.trash_bin) pscript.trash_bin = new pscript.Trash();
+}
+
+pscript.Trash = function() {
+ // create UI elements
+ this.wrapper = $i('trash_div');
+
+ this.head = $a(this.wrapper, 'div');
+ this.body = $a(this.wrapper, 'div');
+ $y(this.body, {margin:'8px'})
+
+ this.make_head();
+ this.load_masters();
+}
+
+// Make Button
+// ------------
+pscript.Trash.prototype.make_button = function(label, area){
+ var me = this;
+ var w = $a(area, 'div', '', {margin:'8px'});
+ var t = make_table(w,1,1,'400px',['50%','50%']);
+ var s = $a($td(t,0,0),'button');
+ s.innerHTML = label;
+ s.wrapper = w;
+ return s;
+}
+
+
+// Make Head
+// -------------
+pscript.Trash.prototype.make_head = function() {
+ var me = this;
+
+ var make_select = function(label) {
+ var w = $a(me.head, 'div', '', {margin:'8px'});
+ var t = make_table(w,1,2,'400px',['50%','50%']);
+ $td(t,0,0).innerHTML = label;
+ var s = $a($td(t,0,1),'select','',{width:'140px'});
+ s.wrapper = w;
+ return s;
+ }
+
+ // Select Master Name
+ this.master_select = make_select('Select Master');
+
+ var me = this;
+ // Get Records
+ this.get_records_button = me.make_button('Get Records', me.head);
+ this.get_records_button.onclick = function() {
+ me.get_records();
+ }
+}
+
+
+// Load Masters
+// -------------
+pscript.Trash.prototype.load_masters = function(){
+ var me = this;
+ var callback = function(r, rt){
+ // Masters
+ empty_select(me.master_select);
+ add_sel_options(me.master_select,add_lists(['All'], r.message), 'All');
+ }
+ $c_obj('Trash Control','get_masters','',callback);
+}
+
+
+// Get Records
+// -----------
+pscript.Trash.prototype.get_records = function(){
+ var me = this;
+ me.body.innerHTML = '';
+ var callback = function(r, rt){
+ if(r.message) me.generate_trash_records(r.message);
+ else msgprint("No Records Found");
+ }
+ $c_obj('Trash Control','get_trash_records',sel_val(me.master_select),callback);
+}
+
+
+// Generate Trash Records
+// -----------------------
+pscript.Trash.prototype.generate_trash_records = function(rec_dict){
+ var me = this;
+ pscript.all_checkboxes = [];
+ mnames = keys(rec_dict).sort();
+ for(var i = 0; i < mnames.length; i ++){
+ var head = $a(me.body, 'h3'); head.innerHTML = mnames[i];
+ var rec_table = make_table(me.body,rec_dict[mnames[i]].length,2,'375px',['350px','25px'],{border:'1px solid #AAA',padding:'2px'});
+ for(var j = 0; j < rec_dict[mnames[i]].length; j++){
+ $a_input($td(rec_table,j,0), 'data');
+ $td(rec_table,j,0).innerHTML = rec_dict[mnames[i]][j];
+ var chk = $a_input($td(rec_table,j,1), 'checkbox');
+ chk.master = mnames[i];
+ chk.record = rec_dict[mnames[i]][j];
+ pscript.all_checkboxes.push(chk);
+ }
+ }
+ this.restore_button = me.make_button('Restore Selected', me.body);
+ this.restore_button.onclick = function() {
+ me.restore_records(0);
+ }
+ this.restore_all_button = me.make_button('Restore All', me.body);
+ this.restore_all_button.onclick = function() {
+ me.restore_records(1);
+ }
+}
+
+
+// Restore Records
+// ---------------
+pscript.Trash.prototype.restore_records = function(restore_all){
+ var me = this;
+ var out = {};
+ for(i in pscript.all_checkboxes) {
+ c = pscript.all_checkboxes[i];
+ if (restore_all || (!restore_all && c.checked)) {
+ if(!out[c.master]) out[c.master] = [c.record];
+ else {out[c.master].push(c.record);}
+ }
+ }
+ $c_obj('Trash Control','restore_records',JSON.stringify(out),function(r, rt){me.get_records();})
+}
\ No newline at end of file
diff --git a/tools/page/trash/trash.txt b/tools/page/trash/trash.txt
new file mode 100644
index 0000000..9be29a9
--- /dev/null
+++ b/tools/page/trash/trash.txt
@@ -0,0 +1 @@
+[{'creation': '2010-04-17 14:36:24', 'module': 'Tools', 'doctype': 'Page', 'owner': 'Administrator', 'style': None, 'modified_by': 'saumil@webnotestech.com', 'script': None, 'show_in_menu': 0, 'content': None, 'page_name': 'Trash', 'menu_index': None, 'docstatus': 0, 'parent': None, 'standard': 'Yes', 'icon': None, 'name': 'Trash', 'idx': None, 'static_content': None, 'modified': '2010-09-25 00:00:00', 'parenttype': None, 'parent_node': None, 'parentfield': None}, {'modified_by': 'saumil@webnotestech.com', 'name': 'PR000122', 'parent': 'Trash', 'creation': '2010-04-19 10:03:20', 'modified': '2010-09-16 16:50:16', 'doctype': 'Page Role', 'idx': 1, 'parenttype': 'Page', 'role': 'Administrator', 'owner': 'Administrator', 'docstatus': 0, 'parentfield': 'roles'}, {'modified_by': 'saumil@webnotestech.com', 'name': 'PR000123', 'parent': 'Trash', 'creation': '2010-04-21 10:33:38', 'modified': '2010-09-16 16:50:16', 'doctype': 'Page Role', 'idx': 2, 'parenttype': 'Page', 'role': 'Sales Master Manager', 'owner': 'saumil@webnotestech.com', 'docstatus': 0, 'parentfield': 'roles'}, {'modified_by': 'saumil@webnotestech.com', 'name': 'PR000124', 'parent': 'Trash', 'creation': '2010-04-21 10:33:38', 'modified': '2010-09-16 16:50:16', 'doctype': 'Page Role', 'idx': 3, 'parenttype': 'Page', 'role': 'Material Master Manager', 'owner': 'saumil@webnotestech.com', 'docstatus': 0, 'parentfield': 'roles'}, {'modified_by': 'saumil@webnotestech.com', 'name': 'PR000125', 'parent': 'Trash', 'creation': '2010-04-21 10:33:38', 'modified': '2010-09-16 16:50:16', 'doctype': 'Page Role', 'idx': 4, 'parenttype': 'Page', 'role': 'Purchase Master Manager', 'owner': 'saumil@webnotestech.com', 'docstatus': 0, 'parentfield': 'roles'}, {'modified_by': 'saumil@webnotestech.com', 'name': 'PR000126', 'parent': 'Trash', 'creation': '2010-04-21 10:33:38', 'modified': '2010-09-16 16:50:16', 'doctype': 'Page Role', 'idx': 5, 'parenttype': 'Page', 'role': 'Accounts Manager', 'owner': 'saumil@webnotestech.com', 'docstatus': 0, 'parentfield': 'roles'}]
\ No newline at end of file
diff --git a/tools/page/wip_monitor/__init__.py b/tools/page/wip_monitor/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tools/page/wip_monitor/__init__.py
diff --git a/tools/page/wip_monitor/wip_monitor.html b/tools/page/wip_monitor/wip_monitor.html
new file mode 100644
index 0000000..b7eb59e
--- /dev/null
+++ b/tools/page/wip_monitor/wip_monitor.html
@@ -0,0 +1,2 @@
+<div id="wip_head"></div>
+<div id="wip_body" style="margin:16px"></div>
\ No newline at end of file
diff --git a/tools/page/wip_monitor/wip_monitor.js b/tools/page/wip_monitor/wip_monitor.js
new file mode 100644
index 0000000..f5a2a62
--- /dev/null
+++ b/tools/page/wip_monitor/wip_monitor.js
@@ -0,0 +1,88 @@
+pscript['onload_WIP Monitor'] = function(){
+ wip = new WIP_Monitor();
+
+ var h = new PageHeader('wip_head','Work in Progress Monitor','A quick glance at your work in progress and pipeline');
+ h.add_button('Refresh', function(){ wip = new WIP_Monitor();}, 1, 'ui-icon-refresh');
+
+}
+
+// Work In Progress Monitor
+// =========================================================================================================================================================
+WIP_Monitor = function(){
+ var me = this;
+ this.row_index = 0;
+ $c_obj('Home Control','get_wip_counts','',function(r,rt){
+ me.make_wip_dashboard(r.message);
+ });
+}
+
+
+// Make wip dashboard
+// ------------------
+WIP_Monitor.prototype.make_wip_dashboard = function(wip_dict)
+{
+ var me = this;
+ // list of doctypes which user can read
+ var can_read_dt = ['Lead', 'Enquiry', 'Sales Order', 'Receivable Voucher', 'Indent', 'Purchase Order', 'Payable Voucher', 'Delivery Note', 'Task', 'Serial No'];
+
+ $i('wip_body').innerHTML = '';
+ this.tab = make_table('wip_body',1,0,'100%',[],{padding:'4px'});
+
+ for(var k=0; k<can_read_dt.length; k++){
+
+ // check if the user can read these doctypes
+ if(in_list(profile.can_read, get_doctype_label(can_read_dt[k])))
+ {
+ var work = can_read_dt[k];
+ if(this.tab.rows[this.row_index].cells.length==2){
+ this.row_index = this.row_index + 1;
+ this.tab.insertRow(this.tab.rows.length);
+ }
+ var parent = this.tab.rows[this.row_index].insertCell(this.tab.rows[this.row_index].cells.length);
+ $y(parent, {paddingBottom:'16px', width:'50%', paddingLeft:'8px'})
+ me.show_wip_dashboard(parent, work, wip_dict[work]);
+ }
+ }
+}
+
+
+// Show wip dashboard
+// ------------------
+WIP_Monitor.prototype.show_wip_dashboard = function(parent, head, report_dict)
+{
+ var me = this;
+ var report_dt
+
+ // dictionary for labels to be displayed
+ var wip_lbl_map = {'Lead':'Lead', 'Enquiry':'Enquiries', 'Sales Order':'Sales Order', 'Receivable Voucher':'Invoices', 'Indent':'Indent', 'Purchase Order':'Purchase Order', 'Payable Voucher':'Bills', 'Delivery Note':'Delivery Note', 'Task':'Tasks', 'Serial No':'Maintenance'};
+
+ // header
+ var h = $a(parent,'h3');
+
+ h.innerHTML = wip_lbl_map[head];
+ report_dt = head;
+
+ for(report in report_dict){
+ me.make_report_body(parent, report, report_dict[report], report_dt);
+ }
+}
+
+
+// Make wip report body
+// --------------------
+WIP_Monitor.prototype.make_report_body = function(parent, lbl, records, rep_dt)
+{
+ var me = this;
+
+ dt_color = lbl=='Overdue' ? 'red' : 'black';
+ var tab2 = make_table(parent,1,2, '70%', ['10%', '90%'], {padding:'4px'});
+
+ // no of records
+ var s1 = $a($td(tab2,0,0), 'span', '', {fontWeight:'bold', fontSize:'12px', color:dt_color});
+ s1.innerHTML = records;
+
+ // link to report
+ var s1 = $a($td(tab2,0,1), 'span', 'link_type', {cursor:'pointer', color:'#DFH'});
+ s1.dt = rep_dt; s1.cn = rep_dt + '-' + lbl; s1.innerHTML = lbl;
+ s1.onclick = function() { loadreport(this.dt, this.cn); }
+}
diff --git a/tools/page/wip_monitor/wip_monitor.txt b/tools/page/wip_monitor/wip_monitor.txt
new file mode 100644
index 0000000..b2394f6
--- /dev/null
+++ b/tools/page/wip_monitor/wip_monitor.txt
@@ -0,0 +1 @@
+[{'creation': '2010-06-29 10:44:15', 'module': 'Tools', 'doctype': 'Page', 'owner': 'Administrator', 'style': None, 'modified_by': 'Administrator', 'script': None, 'show_in_menu': 0, 'content': None, 'page_name': 'WIP Monitor', 'menu_index': None, 'docstatus': 0, 'parent': None, 'standard': 'Yes', 'icon': None, 'name': 'WIP Monitor', 'idx': None, 'static_content': None, 'modified': '2010-11-09 23:12:33', 'parenttype': None, 'parent_node': None, 'parentfield': None}]
\ No newline at end of file