mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-13 02:01:21 +00:00
restructured erpnext and deleted unwanted
This commit is contained in:
0
utilities/doctype/__init__.py
Normal file
0
utilities/doctype/__init__.py
Normal file
@@ -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
|
||||
@@ -0,0 +1,30 @@
|
||||
# DocType, Activity Dashboard Control
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2010-08-08 17:08:51',
|
||||
'docstatus': 0,
|
||||
'modified': '2010-09-20 14:06:57',
|
||||
'modified_by': 'Administrator',
|
||||
'owner': 'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all DocType
|
||||
{
|
||||
'colour': 'White:FFF',
|
||||
'doctype': 'DocType',
|
||||
'issingle': 1,
|
||||
'module': 'Utilities',
|
||||
'name': '__common__',
|
||||
'section_style': 'Simple',
|
||||
'server_code_error': ' ',
|
||||
'version': 42
|
||||
},
|
||||
|
||||
# DocType, Activity Dashboard Control
|
||||
{
|
||||
'doctype': 'DocType',
|
||||
'name': 'Activity Dashboard Control'
|
||||
}
|
||||
]
|
||||
0
utilities/doctype/address/__init__.py
Normal file
0
utilities/doctype/address/__init__.py
Normal file
5
utilities/doctype/address/address.js
Normal file
5
utilities/doctype/address/address.js
Normal file
@@ -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');
|
||||
}
|
||||
|
||||
56
utilities/doctype/address/address.py
Normal file
56
utilities/doctype/address/address.py
Normal file
@@ -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))
|
||||
306
utilities/doctype/address/address.txt
Normal file
306
utilities/doctype/address/address.txt
Normal file
@@ -0,0 +1,306 @@
|
||||
# DocType, Address
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2011-05-24 10:14:48',
|
||||
'docstatus': 0,
|
||||
'modified': '2011-06-09 12:28:53',
|
||||
'modified_by': 'Administrator',
|
||||
'owner': 'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all DocType
|
||||
{
|
||||
'_last_update': '1307602735',
|
||||
'allow_trash': 1,
|
||||
'colour': 'White:FFF',
|
||||
'doctype': 'DocType',
|
||||
'document_type': 'Master',
|
||||
'in_dialog': 1,
|
||||
'module': 'Utilities',
|
||||
'name': '__common__',
|
||||
'section_style': 'Simple',
|
||||
'show_in_menu': 0,
|
||||
'version': 42
|
||||
},
|
||||
|
||||
# These values are common for all DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'name': '__common__',
|
||||
'parent': 'Address',
|
||||
'parentfield': 'fields',
|
||||
'parenttype': 'DocType'
|
||||
},
|
||||
|
||||
# These values are common for all DocPerm
|
||||
{
|
||||
'cancel': 1,
|
||||
'create': 1,
|
||||
'doctype': 'DocPerm',
|
||||
'idx': 1,
|
||||
'name': '__common__',
|
||||
'parent': 'Address',
|
||||
'parentfield': 'permissions',
|
||||
'parenttype': 'DocType',
|
||||
'permlevel': 0,
|
||||
'read': 1,
|
||||
'role': 'All',
|
||||
'write': 1
|
||||
},
|
||||
|
||||
# DocType, Address
|
||||
{
|
||||
'doctype': 'DocType',
|
||||
'name': 'Address'
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'doctype': 'DocPerm'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': 'White:FFF',
|
||||
'doctype': 'DocField',
|
||||
'fieldtype': 'Section Break',
|
||||
'idx': 1,
|
||||
'label': 'Address Details',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': 'White:FFF',
|
||||
'description': '<em>e.g. Office, Billing, Shipping</em>',
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'address_type',
|
||||
'fieldtype': 'Data',
|
||||
'idx': 2,
|
||||
'label': 'Address Type',
|
||||
'permlevel': 0,
|
||||
'reqd': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': 'White:FFF',
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'address_line1',
|
||||
'fieldtype': 'Data',
|
||||
'idx': 3,
|
||||
'label': 'Address Line1',
|
||||
'permlevel': 0,
|
||||
'reqd': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'address_line2',
|
||||
'fieldtype': 'Data',
|
||||
'idx': 4,
|
||||
'label': 'Address Line2',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': 'White:FFF',
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'city',
|
||||
'fieldtype': 'Data',
|
||||
'idx': 5,
|
||||
'in_filter': 1,
|
||||
'label': 'City/Town',
|
||||
'permlevel': 0,
|
||||
'reqd': 1,
|
||||
'search_index': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'pincode',
|
||||
'fieldtype': 'Data',
|
||||
'idx': 6,
|
||||
'in_filter': 1,
|
||||
'label': 'Pincode',
|
||||
'permlevel': 0,
|
||||
'search_index': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': 'White:FFF',
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'country',
|
||||
'fieldtype': 'Select',
|
||||
'idx': 7,
|
||||
'in_filter': 1,
|
||||
'label': 'Country',
|
||||
'options': 'link:Country',
|
||||
'permlevel': 0,
|
||||
'reqd': 1,
|
||||
'search_index': 1,
|
||||
'trigger': 'Client'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': 'White:FFF',
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'state',
|
||||
'fieldtype': 'Data',
|
||||
'idx': 8,
|
||||
'in_filter': 1,
|
||||
'label': 'State',
|
||||
'options': 'Suggest',
|
||||
'permlevel': 0,
|
||||
'search_index': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldtype': 'Column Break',
|
||||
'idx': 9,
|
||||
'permlevel': 0,
|
||||
'print_hide': 0,
|
||||
'width': '50%'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'phone',
|
||||
'fieldtype': 'Data',
|
||||
'idx': 10,
|
||||
'label': 'Phone',
|
||||
'permlevel': 0,
|
||||
'reqd': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'email_id',
|
||||
'fieldtype': 'Data',
|
||||
'idx': 11,
|
||||
'label': 'Email Id',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'fax',
|
||||
'fieldtype': 'Data',
|
||||
'idx': 12,
|
||||
'label': 'Fax',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': 'White:FFF',
|
||||
'depends_on': 'eval:!doc.supplier && !doc.sales_partner',
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'customer',
|
||||
'fieldtype': 'Link',
|
||||
'idx': 13,
|
||||
'label': 'Customer',
|
||||
'options': 'Customer',
|
||||
'permlevel': 0,
|
||||
'trigger': 'Client'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': 'White:FFF',
|
||||
'depends_on': 'eval:!doc.supplier && !doc.sales_partner',
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'customer_name',
|
||||
'fieldtype': 'Data',
|
||||
'idx': 14,
|
||||
'label': 'Customer Name',
|
||||
'permlevel': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': 'White:FFF',
|
||||
'depends_on': 'eval:!doc.customer && !doc.sales_partner',
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'supplier',
|
||||
'fieldtype': 'Link',
|
||||
'idx': 15,
|
||||
'label': 'Supplier',
|
||||
'options': 'Supplier',
|
||||
'permlevel': 0,
|
||||
'trigger': 'Client'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': 'White:FFF',
|
||||
'depends_on': 'eval:!doc.customer && !doc.sales_partner',
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'supplier_name',
|
||||
'fieldtype': 'Data',
|
||||
'idx': 16,
|
||||
'label': 'Supplier Name',
|
||||
'permlevel': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': 'White:FFF',
|
||||
'depends_on': 'eval:!doc.customer && !doc.supplier',
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'sales_partner',
|
||||
'fieldtype': 'Link',
|
||||
'idx': 17,
|
||||
'label': 'Sales Partner',
|
||||
'options': 'Sales Partner',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': 'White:FFF',
|
||||
'default': '0',
|
||||
'description': 'Check to make primary address',
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'is_primary_address',
|
||||
'fieldtype': 'Check',
|
||||
'idx': 18,
|
||||
'label': 'Is Primary Address',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': 'White:FFF',
|
||||
'default': '0',
|
||||
'description': 'Check to make Shipping Address',
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'is_shipping_address',
|
||||
'fieldtype': 'Check',
|
||||
'idx': 19,
|
||||
'label': 'Is Shipping Address',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'trash_reason',
|
||||
'fieldtype': 'Small Text',
|
||||
'idx': 20,
|
||||
'label': 'Trash Reason',
|
||||
'permlevel': 0
|
||||
}
|
||||
]
|
||||
0
utilities/doctype/contact/__init__.py
Normal file
0
utilities/doctype/contact/__init__.py
Normal file
54
utilities/doctype/contact/contact.js
Normal file
54
utilities/doctype/contact/contact.js
Normal file
@@ -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);
|
||||
}
|
||||
*/
|
||||
43
utilities/doctype/contact/contact.py
Normal file
43
utilities/doctype/contact/contact.py
Normal file
@@ -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))
|
||||
339
utilities/doctype/contact/contact.txt
Normal file
339
utilities/doctype/contact/contact.txt
Normal file
@@ -0,0 +1,339 @@
|
||||
# DocType, Contact
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2010-08-08 17:08:55',
|
||||
'docstatus': 0,
|
||||
'modified': '2011-05-26 11:00:36',
|
||||
'modified_by': 'Administrator',
|
||||
'owner': 'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all DocType
|
||||
{
|
||||
'_last_update': '1306307671',
|
||||
'allow_trash': 1,
|
||||
'colour': 'White:FFF',
|
||||
'doctype': 'DocType',
|
||||
'document_type': 'Master',
|
||||
'in_create': 0,
|
||||
'in_dialog': 1,
|
||||
'module': 'Utilities',
|
||||
'name': '__common__',
|
||||
'section_style': 'Simple',
|
||||
'server_code_error': ' ',
|
||||
'show_in_menu': 0,
|
||||
'subject': '%(first_name)s %(last_name)s - Email: %(email_id)s | Contact: %(phone)s | Mobile: %(mobile_no)s',
|
||||
'version': 242
|
||||
},
|
||||
|
||||
# These values are common for all DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'name': '__common__',
|
||||
'parent': 'Contact',
|
||||
'parentfield': 'fields',
|
||||
'parenttype': 'DocType'
|
||||
},
|
||||
|
||||
# These values are common for all DocPerm
|
||||
{
|
||||
'doctype': 'DocPerm',
|
||||
'name': '__common__',
|
||||
'parent': 'Contact',
|
||||
'parentfield': 'permissions',
|
||||
'parenttype': 'DocType',
|
||||
'read': 1
|
||||
},
|
||||
|
||||
# DocType, Contact
|
||||
{
|
||||
'doctype': 'DocType',
|
||||
'name': 'Contact'
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'doctype': 'DocPerm',
|
||||
'idx': 1,
|
||||
'permlevel': 0,
|
||||
'role': 'Sales User'
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'doctype': 'DocPerm',
|
||||
'idx': 2,
|
||||
'permlevel': 0,
|
||||
'role': 'Purchase User'
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'amend': 0,
|
||||
'cancel': 1,
|
||||
'create': 1,
|
||||
'doctype': 'DocPerm',
|
||||
'idx': 3,
|
||||
'permlevel': 0,
|
||||
'role': 'Sales Master Manager',
|
||||
'submit': 0,
|
||||
'write': 1
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'doctype': 'DocPerm',
|
||||
'idx': 4,
|
||||
'permlevel': 1,
|
||||
'role': 'All',
|
||||
'write': 1
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'doctype': 'DocPerm',
|
||||
'idx': 5,
|
||||
'permlevel': 2,
|
||||
'role': 'All'
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'cancel': 1,
|
||||
'create': 1,
|
||||
'doctype': 'DocPerm',
|
||||
'idx': 6,
|
||||
'permlevel': 0,
|
||||
'role': 'Purchase Master Manager',
|
||||
'write': 1
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'cancel': 1,
|
||||
'create': 1,
|
||||
'doctype': 'DocPerm',
|
||||
'idx': 7,
|
||||
'permlevel': 0,
|
||||
'role': 'System Manager',
|
||||
'write': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': 'White:FFF',
|
||||
'doctype': 'DocField',
|
||||
'fieldtype': 'Section Break',
|
||||
'idx': 1,
|
||||
'label': 'Contact Details',
|
||||
'oldfieldtype': 'Section Break',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldtype': 'Column Break',
|
||||
'idx': 2,
|
||||
'oldfieldtype': 'Column Break',
|
||||
'permlevel': 0,
|
||||
'width': '50%'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'first_name',
|
||||
'fieldtype': 'Data',
|
||||
'idx': 3,
|
||||
'label': 'First Name',
|
||||
'oldfieldname': 'first_name',
|
||||
'oldfieldtype': 'Data',
|
||||
'permlevel': 0,
|
||||
'reqd': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'last_name',
|
||||
'fieldtype': 'Data',
|
||||
'idx': 4,
|
||||
'label': 'Last Name',
|
||||
'oldfieldname': 'last_name',
|
||||
'oldfieldtype': 'Data',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': 'White:FFF',
|
||||
'depends_on': 'eval:!doc.supplier && !doc.sales_partner',
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'customer',
|
||||
'fieldtype': 'Link',
|
||||
'idx': 5,
|
||||
'label': 'Customer',
|
||||
'oldfieldname': 'customer',
|
||||
'oldfieldtype': 'Link',
|
||||
'options': 'Customer',
|
||||
'permlevel': 0,
|
||||
'print_hide': 0,
|
||||
'trigger': 'Client'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': 'White:FFF',
|
||||
'depends_on': 'eval:!doc.supplier && !doc.sales_partner',
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'customer_name',
|
||||
'fieldtype': 'Data',
|
||||
'idx': 6,
|
||||
'label': 'Customer Name',
|
||||
'permlevel': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': 'White:FFF',
|
||||
'depends_on': 'eval:!doc.customer && !doc.sales_partner',
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'supplier',
|
||||
'fieldtype': 'Link',
|
||||
'idx': 7,
|
||||
'label': 'Supplier',
|
||||
'options': 'Supplier',
|
||||
'permlevel': 0,
|
||||
'trigger': 'Client'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'allow_on_submit': 0,
|
||||
'colour': 'White:FFF',
|
||||
'depends_on': 'eval:!doc.customer && !doc.sales_partner',
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'supplier_name',
|
||||
'fieldtype': 'Data',
|
||||
'idx': 8,
|
||||
'label': 'Supplier Name',
|
||||
'permlevel': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': 'White:FFF',
|
||||
'depends_on': 'eval:!doc.customer && !doc.supplier',
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'sales_partner',
|
||||
'fieldtype': 'Link',
|
||||
'idx': 9,
|
||||
'label': 'Sales Partner',
|
||||
'options': 'Sales Partner',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': 'White:FFF',
|
||||
'default': '0',
|
||||
'depends_on': 'eval:(cint(doc.is_customer) || cint(doc.is_supplier) || cint(doc.is_sales_partner))',
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'is_primary_contact',
|
||||
'fieldtype': 'Check',
|
||||
'idx': 10,
|
||||
'label': 'Is Primary Contact',
|
||||
'oldfieldname': 'is_primary_contact',
|
||||
'oldfieldtype': 'Select',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldtype': 'Column Break',
|
||||
'idx': 11,
|
||||
'oldfieldtype': 'Column Break',
|
||||
'permlevel': 0,
|
||||
'width': '50%'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'email_id',
|
||||
'fieldtype': 'Data',
|
||||
'idx': 12,
|
||||
'label': 'Email Id',
|
||||
'oldfieldname': 'email_id',
|
||||
'oldfieldtype': 'Data',
|
||||
'permlevel': 0,
|
||||
'reqd': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'phone',
|
||||
'fieldtype': 'Data',
|
||||
'idx': 13,
|
||||
'label': 'Phone',
|
||||
'oldfieldname': 'contact_no',
|
||||
'oldfieldtype': 'Data',
|
||||
'permlevel': 0,
|
||||
'reqd': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'mobile_no',
|
||||
'fieldtype': 'Data',
|
||||
'idx': 14,
|
||||
'label': 'Mobile No',
|
||||
'oldfieldname': 'mobile_no',
|
||||
'oldfieldtype': 'Data',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': 'White:FFF',
|
||||
'description': 'Enter department to which this Contact belongs',
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'department',
|
||||
'fieldtype': 'Data',
|
||||
'idx': 15,
|
||||
'label': 'Department',
|
||||
'options': 'Suggest',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': 'White:FFF',
|
||||
'description': 'Enter designation of this Contact',
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'designation',
|
||||
'fieldtype': 'Data',
|
||||
'idx': 16,
|
||||
'label': 'Designation',
|
||||
'options': 'Suggest',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'trash_reason',
|
||||
'fieldtype': 'Small Text',
|
||||
'idx': 17,
|
||||
'label': 'Trash Reason',
|
||||
'oldfieldname': 'trash_reason',
|
||||
'oldfieldtype': 'Small Text',
|
||||
'permlevel': 1
|
||||
}
|
||||
]
|
||||
0
utilities/doctype/contact_detail/__init__.py
Normal file
0
utilities/doctype/contact_detail/__init__.py
Normal file
98
utilities/doctype/contact_detail/contact_detail.txt
Normal file
98
utilities/doctype/contact_detail/contact_detail.txt
Normal file
@@ -0,0 +1,98 @@
|
||||
# DocType, Contact Detail
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2010-08-08 17:08:56',
|
||||
'docstatus': 0,
|
||||
'modified': '2010-09-20 14:06:57',
|
||||
'modified_by': 'Administrator',
|
||||
'owner': 'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all DocType
|
||||
{
|
||||
'autoname': 'CD/.#####',
|
||||
'colour': 'White:FFF',
|
||||
'doctype': 'DocType',
|
||||
'istable': 1,
|
||||
'module': 'Utilities',
|
||||
'name': '__common__',
|
||||
'section_style': 'Tray',
|
||||
'show_in_menu': 0,
|
||||
'version': 5
|
||||
},
|
||||
|
||||
# These values are common for all DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'name': '__common__',
|
||||
'parent': 'Contact Detail',
|
||||
'parentfield': 'fields',
|
||||
'parenttype': 'DocType',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocType, Contact Detail
|
||||
{
|
||||
'doctype': 'DocType',
|
||||
'name': 'Contact Detail'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'contact_person',
|
||||
'fieldtype': 'Data',
|
||||
'idx': 1,
|
||||
'label': 'Contact Person',
|
||||
'oldfieldname': 'contact_person',
|
||||
'oldfieldtype': 'Data',
|
||||
'reqd': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'contact_no',
|
||||
'fieldtype': 'Data',
|
||||
'idx': 2,
|
||||
'label': 'Contact No',
|
||||
'oldfieldname': 'contact_no',
|
||||
'oldfieldtype': 'Data',
|
||||
'reqd': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'department',
|
||||
'fieldtype': 'Data',
|
||||
'idx': 3,
|
||||
'label': 'Department',
|
||||
'oldfieldname': 'department',
|
||||
'oldfieldtype': 'Data'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'designation',
|
||||
'fieldtype': 'Data',
|
||||
'idx': 4,
|
||||
'label': 'Designation',
|
||||
'oldfieldname': 'designation',
|
||||
'oldfieldtype': 'Data'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'email_id',
|
||||
'fieldtype': 'Small Text',
|
||||
'idx': 5,
|
||||
'label': 'Email Id',
|
||||
'oldfieldname': 'email_id',
|
||||
'oldfieldtype': 'Small Text'
|
||||
}
|
||||
]
|
||||
0
utilities/doctype/doctype_label/__init__.py
Normal file
0
utilities/doctype/doctype_label/__init__.py
Normal file
1
utilities/doctype/doctype_label/doctype_label.txt
Normal file
1
utilities/doctype/doctype_label/doctype_label.txt
Normal file
@@ -0,0 +1 @@
|
||||
[{'section_style': 'Simple', 'is_transaction_doc': None, 'creation': '2010-06-10 10:41:58', 'search_fields': None, 'module': 'Application Internal', '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': None, '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': 'field:dt', 'client_script_core': None, 'client_string': None, 'use_template': None, 'modified_by': 'Administrator', 'document_type': None, 'name': 'DocType Label', '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': 'PERM01036', 'parent': 'DocType Label', 'read': 1, 'create': 1, 'creation': '2010-06-10 10:41:58', 'modified': '2010-06-10 10:44:09', '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': 'Select', 'creation': '2010-06-10 10:41:58', 'doctype': 'DocField', 'oldfieldname': 'dt', 'owner': 'Administrator', 'reqd': 1, 'in_filter': None, 'print_hide': None, 'modified_by': 'Administrator', 'label': 'Select DocType', 'width': None, 'trigger': None, 'depends_on': None, 'docstatus': 0, 'hidden': None, 'permlevel': 0, 'description': None, 'parent': 'DocType Label', 'search_index': None, 'allow_on_submit': None, 'icon': None, 'name': 'FL05322', 'idx': 1, 'default': None, 'colour': None, 'modified': '2010-06-10 10:44:09', 'parenttype': 'DocType', 'fieldname': 'dt', 'fieldtype': 'Select', 'options': 'link:DocType', 'report_hide': None, 'parentfield': 'fields'}, {'no_copy': None, 'oldfieldtype': 'Data', 'creation': '2010-06-10 10:41:58', 'doctype': 'DocField', 'oldfieldname': 'dt_label', 'owner': 'Administrator', 'reqd': 1, 'in_filter': None, 'print_hide': None, 'modified_by': 'Administrator', 'label': 'DocType Label', 'width': None, 'trigger': None, 'depends_on': None, 'docstatus': 0, 'hidden': None, 'permlevel': 0, 'description': None, 'parent': 'DocType Label', 'search_index': None, 'allow_on_submit': None, 'icon': None, 'name': 'FL05323', 'idx': 2, 'default': None, 'colour': None, 'modified': '2010-06-10 10:44:09', 'parenttype': 'DocType', 'fieldname': 'dt_label', 'fieldtype': 'Data', 'options': None, 'report_hide': None, 'parentfield': 'fields'}]
|
||||
@@ -0,0 +1,15 @@
|
||||
class DocType:
|
||||
def __init__(self,d,dl):
|
||||
self.doc, self.doclist = d, dl
|
||||
|
||||
def update_dt(self):
|
||||
sql("update tabDocType set module=%s, autoname=%s, read_only_onload=%s, section_style=%s, description=%s where name=%s limit 1", (self.doc.module, self.doc.autoname, self.doc.show_print_format_first, self.doc.page_style, self.doc.description, self.doc.select_doctype))
|
||||
|
||||
def get_details(self):
|
||||
ret = sql("select module, autoname, read_only_onload, section_style, description from tabDocType where name=%s", (self.doc.select_doctype))
|
||||
self.doc.module = ret[0][0] or ''
|
||||
self.doc.autoname = ret[0][1] or ''
|
||||
self.doc.show_print_format_first = ret[0][2] or 0
|
||||
self.doc.page_style = ret[0][3] or 'Simple'
|
||||
self.doc.description = ret[0][4] or ''
|
||||
|
||||
@@ -0,0 +1,138 @@
|
||||
# DocType, DocType Property Setter
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2010-08-08 17:08:59',
|
||||
'docstatus': 0,
|
||||
'modified': '2010-09-20 14:06:57',
|
||||
'modified_by': 'Administrator',
|
||||
'owner': 'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all DocType
|
||||
{
|
||||
'colour': 'White:FFF',
|
||||
'doctype': 'DocType',
|
||||
'issingle': 1,
|
||||
'module': 'Utilities',
|
||||
'name': '__common__',
|
||||
'section_style': 'Simple',
|
||||
'server_code_error': ' ',
|
||||
'version': 4
|
||||
},
|
||||
|
||||
# These values are common for all DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'name': '__common__',
|
||||
'parent': 'DocType Property Setter',
|
||||
'parentfield': 'fields',
|
||||
'parenttype': 'DocType',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# These values are common for all DocPerm
|
||||
{
|
||||
'create': 1,
|
||||
'doctype': 'DocPerm',
|
||||
'idx': 1,
|
||||
'name': '__common__',
|
||||
'parent': 'DocType Property Setter',
|
||||
'parentfield': 'permissions',
|
||||
'parenttype': 'DocType',
|
||||
'permlevel': 0,
|
||||
'read': 1,
|
||||
'role': 'System Manager',
|
||||
'write': 1
|
||||
},
|
||||
|
||||
# DocType, DocType Property Setter
|
||||
{
|
||||
'doctype': 'DocType',
|
||||
'name': 'DocType Property Setter'
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'doctype': 'DocPerm'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'select_doctype',
|
||||
'fieldtype': 'Select',
|
||||
'idx': 1,
|
||||
'label': 'Select DocType',
|
||||
'options': 'link:DocType'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldtype': 'Button',
|
||||
'idx': 2,
|
||||
'label': 'Get Details',
|
||||
'options': 'get_details',
|
||||
'trigger': 'Server'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'module',
|
||||
'fieldtype': 'Link',
|
||||
'idx': 3,
|
||||
'label': 'Module',
|
||||
'options': 'Module Def'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'autoname',
|
||||
'fieldtype': 'Data',
|
||||
'idx': 4,
|
||||
'label': 'Autoname'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'page_style',
|
||||
'fieldtype': 'Select',
|
||||
'idx': 5,
|
||||
'label': 'Page Style',
|
||||
'options': 'Simple\nTabbed\nTray'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'show_print_format_first',
|
||||
'fieldtype': 'Check',
|
||||
'idx': 6,
|
||||
'label': 'Show Print Format First'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'description',
|
||||
'fieldtype': 'Text Editor',
|
||||
'idx': 7,
|
||||
'label': 'Description',
|
||||
'width': '300px'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldtype': 'Button',
|
||||
'idx': 8,
|
||||
'label': 'Update',
|
||||
'options': 'update_dt',
|
||||
'trigger': 'Server'
|
||||
}
|
||||
]
|
||||
0
utilities/doctype/file_browser_control/__init__.py
Normal file
0
utilities/doctype/file_browser_control/__init__.py
Normal file
198
utilities/doctype/file_browser_control/file_browser_control.py
Normal file
198
utilities/doctype/file_browser_control/file_browser_control.py
Normal file
@@ -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
|
||||
@@ -0,0 +1,31 @@
|
||||
# DocType, File Browser Control
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2009-10-28 10:25:03',
|
||||
'docstatus': 0,
|
||||
'modified': '2010-12-27 11:09:53',
|
||||
'modified_by': 'umair@iwebnotes.com',
|
||||
'owner': 'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all DocType
|
||||
{
|
||||
'colour': 'White:FFF',
|
||||
'doctype': 'DocType',
|
||||
'issingle': 1,
|
||||
'module': 'Utilities',
|
||||
'name': '__common__',
|
||||
'section_style': 'Simple',
|
||||
'server_code_error': ' ',
|
||||
'show_in_menu': 0,
|
||||
'version': 81
|
||||
},
|
||||
|
||||
# DocType, File Browser Control
|
||||
{
|
||||
'doctype': 'DocType',
|
||||
'name': 'File Browser Control'
|
||||
}
|
||||
]
|
||||
0
utilities/doctype/gl_mapper/__init__.py
Normal file
0
utilities/doctype/gl_mapper/__init__.py
Normal file
98
utilities/doctype/gl_mapper/gl_mapper.txt
Normal file
98
utilities/doctype/gl_mapper/gl_mapper.txt
Normal file
@@ -0,0 +1,98 @@
|
||||
# DocType, GL Mapper
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2010-08-08 17:09:03',
|
||||
'docstatus': 0,
|
||||
'modified': '2011-05-10 11:16:01',
|
||||
'modified_by': 'Administrator',
|
||||
'owner': 'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all DocType
|
||||
{
|
||||
'_last_update': '1305006361',
|
||||
'autoname': 'field:doc_type',
|
||||
'colour': 'White:FFF',
|
||||
'doctype': 'DocType',
|
||||
'module': 'Utilities',
|
||||
'name': '__common__',
|
||||
'section_style': 'Simple',
|
||||
'server_code_error': ' ',
|
||||
'show_in_menu': 0,
|
||||
'version': 3
|
||||
},
|
||||
|
||||
# These values are common for all DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'name': '__common__',
|
||||
'parent': 'GL Mapper',
|
||||
'parentfield': 'fields',
|
||||
'parenttype': 'DocType',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# These values are common for all DocPerm
|
||||
{
|
||||
'doctype': 'DocPerm',
|
||||
'name': '__common__',
|
||||
'parent': 'GL Mapper',
|
||||
'parentfield': 'permissions',
|
||||
'parenttype': 'DocType',
|
||||
'permlevel': 0,
|
||||
'read': 1
|
||||
},
|
||||
|
||||
# DocType, GL Mapper
|
||||
{
|
||||
'doctype': 'DocType',
|
||||
'name': 'GL Mapper'
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'amend': 0,
|
||||
'cancel': 0,
|
||||
'create': 0,
|
||||
'doctype': 'DocPerm',
|
||||
'idx': 1,
|
||||
'role': 'Accounts User',
|
||||
'submit': 0,
|
||||
'write': 0
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'create': 1,
|
||||
'doctype': 'DocPerm',
|
||||
'idx': 2,
|
||||
'role': 'System Manager',
|
||||
'write': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'doc_type',
|
||||
'fieldtype': 'Data',
|
||||
'idx': 1,
|
||||
'label': 'Doc Type',
|
||||
'oldfieldname': 'doc_type',
|
||||
'oldfieldtype': 'Link',
|
||||
'reqd': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'fields',
|
||||
'fieldtype': 'Table',
|
||||
'idx': 2,
|
||||
'label': 'Fields',
|
||||
'oldfieldname': 'fields',
|
||||
'oldfieldtype': 'Table',
|
||||
'options': 'GL Mapper Detail'
|
||||
}
|
||||
]
|
||||
0
utilities/doctype/gl_mapper_detail/__init__.py
Normal file
0
utilities/doctype/gl_mapper_detail/__init__.py
Normal file
225
utilities/doctype/gl_mapper_detail/gl_mapper_detail.txt
Normal file
225
utilities/doctype/gl_mapper_detail/gl_mapper_detail.txt
Normal file
@@ -0,0 +1,225 @@
|
||||
# DocType, GL Mapper Detail
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2010-08-08 17:09:03',
|
||||
'docstatus': 0,
|
||||
'modified': '2010-09-20 14:06:57',
|
||||
'modified_by': 'Administrator',
|
||||
'owner': 'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all DocType
|
||||
{
|
||||
'autoname': 'GLMDetail.#####',
|
||||
'colour': 'White:FFF',
|
||||
'doctype': 'DocType',
|
||||
'istable': 1,
|
||||
'module': 'Utilities',
|
||||
'name': '__common__',
|
||||
'section_style': 'Tray',
|
||||
'server_code_error': ' ',
|
||||
'show_in_menu': 0,
|
||||
'version': 3
|
||||
},
|
||||
|
||||
# These values are common for all DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldtype': 'Data',
|
||||
'name': '__common__',
|
||||
'oldfieldtype': 'Data',
|
||||
'parent': 'GL Mapper Detail',
|
||||
'parentfield': 'fields',
|
||||
'parenttype': 'DocType',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocType, GL Mapper Detail
|
||||
{
|
||||
'doctype': 'DocType',
|
||||
'name': 'GL Mapper Detail'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'table_field',
|
||||
'idx': 1,
|
||||
'label': 'Table Field',
|
||||
'oldfieldname': 'table_field'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'account',
|
||||
'idx': 2,
|
||||
'label': 'Account',
|
||||
'oldfieldname': 'account',
|
||||
'reqd': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'debit',
|
||||
'idx': 3,
|
||||
'label': 'Debit',
|
||||
'oldfieldname': 'debit',
|
||||
'reqd': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'credit',
|
||||
'idx': 4,
|
||||
'label': 'Credit',
|
||||
'oldfieldname': 'credit',
|
||||
'reqd': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'cost_center',
|
||||
'idx': 5,
|
||||
'label': 'Cost Center',
|
||||
'oldfieldname': 'cost_center',
|
||||
'reqd': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'against',
|
||||
'idx': 6,
|
||||
'label': 'Against',
|
||||
'oldfieldname': 'against',
|
||||
'reqd': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'remarks',
|
||||
'idx': 7,
|
||||
'label': 'Remarks',
|
||||
'no_copy': 1,
|
||||
'oldfieldname': 'remarks',
|
||||
'reqd': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'voucher_type',
|
||||
'idx': 8,
|
||||
'label': 'Voucher Type',
|
||||
'oldfieldname': 'voucher_type',
|
||||
'reqd': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'voucher_no',
|
||||
'idx': 9,
|
||||
'label': 'Voucher No',
|
||||
'oldfieldname': 'voucher_no',
|
||||
'reqd': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'description': 'The date at which current entry will get or has actually executed.',
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'posting_date',
|
||||
'idx': 10,
|
||||
'label': 'Posting Date',
|
||||
'oldfieldname': 'posting_date',
|
||||
'reqd': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'description': 'The date at which current entry is made in system.',
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'transaction_date',
|
||||
'idx': 11,
|
||||
'label': 'Transaction Date',
|
||||
'oldfieldname': 'transaction_date',
|
||||
'reqd': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'aging_date',
|
||||
'idx': 12,
|
||||
'label': 'Aging Date',
|
||||
'oldfieldname': 'aging_date',
|
||||
'reqd': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'fiscal_year',
|
||||
'idx': 13,
|
||||
'in_filter': 1,
|
||||
'label': 'Fiscal Year',
|
||||
'oldfieldname': 'fiscal_year',
|
||||
'reqd': 1,
|
||||
'search_index': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'against_voucher',
|
||||
'idx': 14,
|
||||
'label': 'Against Voucher',
|
||||
'oldfieldname': 'against_voucher'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'against_voucher_type',
|
||||
'idx': 15,
|
||||
'label': 'Against Voucher Type',
|
||||
'oldfieldname': 'against_voucher_type'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'company',
|
||||
'idx': 16,
|
||||
'in_filter': 1,
|
||||
'label': 'Company',
|
||||
'oldfieldname': 'company',
|
||||
'search_index': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'is_opening',
|
||||
'idx': 17,
|
||||
'label': 'Is Opening',
|
||||
'oldfieldname': 'is_opening'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'is_advance',
|
||||
'idx': 18,
|
||||
'label': 'Is Advance',
|
||||
'oldfieldname': 'is_advance'
|
||||
}
|
||||
]
|
||||
0
utilities/doctype/menu_control/__init__.py
Normal file
0
utilities/doctype/menu_control/__init__.py
Normal file
82
utilities/doctype/menu_control/menu_control.js
Normal file
82
utilities/doctype/menu_control/menu_control.js
Normal file
@@ -0,0 +1,82 @@
|
||||
class DocType:
|
||||
def __init__(self, d, dl):
|
||||
self.doc, self.doclist = d,dl
|
||||
|
||||
def get_children(self, arg='', only_type='', in_roles=[]):
|
||||
|
||||
type_cond = only_type and (" and menu_item_type='%s'" % only_type) or ''
|
||||
|
||||
if globals().has_key('version') and version=='v170':
|
||||
import webnotes
|
||||
roles = webnotes.user.get_roles()
|
||||
all_read = webnotes.user.can_read
|
||||
else:
|
||||
roles = in_roles or session['data']['roles']
|
||||
all_read = session['data']['all_readtypes']
|
||||
|
||||
cl = sql("select name, menu_item_label, menu_item_type, link_id, link_content, has_children, icon, `order`, criteria_name, doctype_fields, onload from `tabMenu Item` where ifnull(disabled,'No')!='Yes' and ifnull(parent_menu_item,'')='%s' %s order by `order` asc" % (arg, type_cond), as_dict=1)
|
||||
ol = []
|
||||
for c in cl:
|
||||
c['has_children'] = cint(c['has_children'])
|
||||
c['order'] = cint(c['order'])
|
||||
for k in c.keys():
|
||||
if c[k]==None: c[k] = ''
|
||||
|
||||
# check permission
|
||||
if c['menu_item_type'] in ('DocType','Single','Report'):
|
||||
if c['link_id'] in all_read:
|
||||
ol.append(c)
|
||||
elif c['menu_item_type']=='Page':
|
||||
# page
|
||||
if c['link_id'].startswith('_'):
|
||||
ol.append(c)
|
||||
elif has_common([r[0] for r in sql("select role from `tabPage Role` where parent=%s", c['link_id'])], roles):
|
||||
ol.append(c)
|
||||
elif cstr(c['menu_item_type'])=='':
|
||||
# sections
|
||||
if has_common([r[0] for r in sql("select role from `tabMenu Item Role` where parent=%s", c['name'])], roles):
|
||||
ol.append(c)
|
||||
else:
|
||||
ol.append(c)
|
||||
|
||||
return ol
|
||||
|
||||
def get_dt_details(self, arg):
|
||||
dt, fl = arg.split('~~~')
|
||||
|
||||
out = {}
|
||||
|
||||
# filters
|
||||
# -------
|
||||
|
||||
sf = sql("select search_fields from tabDocType where name=%s", dt)[0][0] or ''
|
||||
sf = [s.strip() for s in sf.split(',')]
|
||||
if sf and sf[0]:
|
||||
res = sql("select fieldname, label, fieldtype, options from tabDocField where parent='%s' and fieldname in (%s)" % (dt, '"'+'","'.join(sf)+'"'))
|
||||
else:
|
||||
res = []
|
||||
|
||||
res = [[c or '' for c in r] for r in res]
|
||||
for r in res:
|
||||
if r[2]=='Select' and r[3] and r[3].startswith('link:'):
|
||||
tdt = r[3][5:]
|
||||
ol = sql("select name from `tab%s` where docstatus!=2 order by name asc" % tdt)
|
||||
r[3] = NEWLINE.join([''] + [o[0] for o in ol])
|
||||
|
||||
if not res:
|
||||
out['filters'] = [['name', 'ID', 'Data', '']]
|
||||
else:
|
||||
out['filters'] = res
|
||||
|
||||
# columns
|
||||
# -------
|
||||
fl = fl.split(NEWLINE)
|
||||
fl = [f.split(',')[0] for f in fl]
|
||||
res = []
|
||||
for f in fl:
|
||||
res += [[c or '' for c in r] for r in sql("select fieldname, label, fieldtype, options from tabDocField where parent='%s' and fieldname='%s'" % (dt, f))]
|
||||
|
||||
out['columns'] = [['name', 'ID', 'Link', dt]] + res
|
||||
|
||||
return out
|
||||
|
||||
265
utilities/doctype/menu_control/menu_control.py
Normal file
265
utilities/doctype/menu_control/menu_control.py
Normal file
@@ -0,0 +1,265 @@
|
||||
# Please edit this list and import only required elements
|
||||
import webnotes
|
||||
|
||||
from webnotes.utils import cint, cstr
|
||||
from webnotes.model.doc import Document
|
||||
from webnotes.model.code import get_obj
|
||||
from webnotes import session, form, msgprint, errprint
|
||||
|
||||
sql = webnotes.conn.sql
|
||||
convert_to_lists = webnotes.conn.convert_to_lists
|
||||
|
||||
# -----------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
class DocType:
|
||||
def __init__(self, d, dl):
|
||||
self.doc, self.doclist = d,dl
|
||||
|
||||
# --------------------------------------------------------------
|
||||
def get_children(self, arg='', only_type='', in_roles=[]):
|
||||
|
||||
type_cond = only_type and (" and menu_item_type='%s'" % only_type) or ''
|
||||
|
||||
import webnotes
|
||||
roles = webnotes.user.get_roles()
|
||||
all_read = webnotes.user.can_get_report
|
||||
|
||||
cl = sql("select name, menu_item_label, menu_item_type, link_id, link_content, has_children, icon, `order`, criteria_name, doctype_fields, onload from `tabMenu Item` where ifnull(disabled,'No')!='Yes' and ifnull(parent_menu_item,'')='%s' %s order by `order` asc" % (arg, type_cond), as_dict=1)
|
||||
ol = []
|
||||
for c in cl:
|
||||
c['has_children'] = cint(c['has_children'])
|
||||
c['order'] = cint(c['order'])
|
||||
for k in c.keys():
|
||||
if c[k]==None: c[k] = ''
|
||||
|
||||
# check permission
|
||||
if c['menu_item_type'] in ('DocType','Single','Report'):
|
||||
if c['link_id'] in all_read:
|
||||
ol.append(c)
|
||||
elif c['menu_item_type']=='Page':
|
||||
# page
|
||||
if c['link_id'].startswith('_'):
|
||||
ol.append(c)
|
||||
elif has_common([r[0] for r in sql("select role from `tabPage Role` where parent=%s", c['link_id'])], roles):
|
||||
ol.append(c)
|
||||
elif cstr(c['menu_item_type'])=='':
|
||||
# sections
|
||||
if has_common([r[0] for r in sql("select role from `tabMenu Item Role` where parent=%s", c['name'])], roles):
|
||||
ol.append(c)
|
||||
else:
|
||||
ol.append(c)
|
||||
|
||||
return ol
|
||||
|
||||
# --------------------------------------------------------------
|
||||
def has_result(self, dt):
|
||||
return sql("select name from `tab%s` limit 1" % dt) and 'Yes' or 'No'
|
||||
|
||||
# --------------------------------------------------------------
|
||||
|
||||
def is_submittable(self, dt):
|
||||
return sql("select name from tabDocPerm where parent=%s and ifnull(submit,0)=1 and docstatus<1 limit 1", dt)
|
||||
|
||||
# --------------------------------------------------------------
|
||||
|
||||
def can_cancel(self, dt):
|
||||
return sql('select name from tabDocPerm where parent="%s" and ifnull(cancel,0)=1 and docstatus<1 and role in ("%s") limit 1' % (dt, '", "'.join(webnotes.user.get_roles())))
|
||||
|
||||
# --------------------------------------------------------------
|
||||
def get_dt_trend(self, dt):
|
||||
ret = {}
|
||||
for r in sql("select datediff(now(),modified), count(*) from `tab%s` where datediff(now(),modified) between 0 and 30 group by date(modified)" % dt):
|
||||
ret[cint(r[0])] = cint(r[1])
|
||||
return ret
|
||||
|
||||
# --------------------------------------------------------------
|
||||
|
||||
def get_columns(self, out, sf, fl, dt):
|
||||
if not fl:
|
||||
fl = sf
|
||||
|
||||
res = []
|
||||
for f in fl:
|
||||
if f:
|
||||
res += [[c or '' for c in r] for r in sql("select fieldname, label, fieldtype, options from tabDocField where parent='%s' and fieldname='%s'" % (dt, f))]
|
||||
|
||||
return res
|
||||
|
||||
# --------------------------------------------------------------
|
||||
|
||||
def check_user_tags(self, dt):
|
||||
try:
|
||||
sql("select `_user_tags` from `tab%s` limit 1" % dt)
|
||||
except Exception, e:
|
||||
if e.args[0] == 1054:
|
||||
webnotes.conn.commit()
|
||||
sql("alter table `tab%s` add column `_user_tags` varchar(180)" % dt)
|
||||
webnotes.conn.begin()
|
||||
|
||||
# --------------------------------------------------------------
|
||||
# NOTE: THIS SHOULD BE CACHED IN DOCTYPE CACHE
|
||||
# --------------------------------------------------------------
|
||||
|
||||
def get_dt_details(self, arg):
|
||||
dt, fl, color_map = eval(arg)
|
||||
submittable = self.is_submittable(dt) and 1 or 0
|
||||
|
||||
out = {
|
||||
'submittable':(self.is_submittable(dt) and 1 or 0),
|
||||
'can_cancel':(self.can_cancel(dt) and 1 or 0)
|
||||
}
|
||||
|
||||
# filters
|
||||
# -------
|
||||
|
||||
sf = sql("select search_fields from tabDocType where name=%s", dt)[0][0] or ''
|
||||
|
||||
# get fields from in_filter (if not in search_fields)
|
||||
if not sf.strip():
|
||||
res = sql("select fieldname, label, fieldtype, options from tabDocField where parent=%s and `in_filter` = 1 and ifnull(fieldname,'') != ''", dt)
|
||||
sf = [s[0] for s in res]
|
||||
else:
|
||||
sf = [s.strip() for s in sf.split(',')]
|
||||
res = sql("select fieldname, label, fieldtype, options from tabDocField where parent='%s' and fieldname in (%s)" % (dt, '"'+'","'.join(sf)+'"'))
|
||||
|
||||
# select "link" options
|
||||
res = [[c or '' for c in r] for r in res]
|
||||
for r in res:
|
||||
if r[2]=='Select' and r[3] and r[3].startswith('link:'):
|
||||
tdt = r[3][5:]
|
||||
ol = sql("select name from `tab%s` where docstatus!=2 order by name asc" % tdt)
|
||||
r[3] = "\n".join([''] + [o[0] for o in ol])
|
||||
|
||||
if not res:
|
||||
out['filters'] = [['name', 'ID', 'Data', '']]
|
||||
else:
|
||||
out['filters'] = [['name', 'ID', 'Data', '']] + res
|
||||
|
||||
# columns
|
||||
# -------
|
||||
res = self.get_columns(out, sf, fl, dt)
|
||||
|
||||
self.check_user_tags(dt)
|
||||
|
||||
out['columns'] = [['name', 'ID', 'Link', dt], ['modified', 'Modified', 'Data', ''], ['_user_tags', 'Tags', 'Data', '']] + res
|
||||
|
||||
if cint(color_map):
|
||||
out['color_map'] = self.get_color_map()
|
||||
|
||||
return out
|
||||
|
||||
# --------------------------------------------------------------
|
||||
|
||||
def get_color_map(self):
|
||||
d={}
|
||||
try:
|
||||
for tag in sql("select name, tag_color from tabTag"):
|
||||
d[tag[0]] = tag[1]
|
||||
except Exception, e:
|
||||
if e.args[0] in (1146, 1054):
|
||||
return {}
|
||||
else:
|
||||
raise e
|
||||
return d
|
||||
|
||||
# --------------------------------------------------------------
|
||||
|
||||
def get_trend(self, dt):
|
||||
return {'trend': self.get_dt_trend(dt)}
|
||||
|
||||
# --------------------------------------------------------------
|
||||
|
||||
def get_tags(self, dt, dn):
|
||||
tl = sql("select ifnull(_user_tags,'') from tab%s where name=%s" % (dt,'%s'), dn)[0][0]
|
||||
return tl and tl.split(',') or []
|
||||
|
||||
# --------------------------------------------------------------
|
||||
|
||||
def update_tags(self, dt, dn, tl):
|
||||
if len(','.join(tl)) > 179:
|
||||
msgprint("Too many tags")
|
||||
raise Exception
|
||||
|
||||
tl = filter(lambda x: x, tl)
|
||||
|
||||
# update in table
|
||||
sql("update tab%s set _user_tags=%s where name=%s" % (dt,'%s','%s'), (',' + ','.join(tl), dn))
|
||||
|
||||
# update in feed (if present)
|
||||
sql("update tabFeed set _user_tags=%s where doc_label=%s and doc_name=%s", (',' + ','.join(tl), dt, dn))
|
||||
|
||||
# --------------------------------------------------------------
|
||||
|
||||
def _add_tag_to_master(self, tag, color):
|
||||
if color:
|
||||
t, cond = color, ("on duplicate key update tag_color='%s'" % color)
|
||||
else:
|
||||
t, cond = 'Default', ''
|
||||
|
||||
sql("insert ignore into tabTag(name, tag_color) values ('%s', '%s') %s" % (tag, t, cond))
|
||||
|
||||
def create_tag(self, tag, color):
|
||||
try:
|
||||
self._add_tag_to_master(tag, color)
|
||||
except Exception, e:
|
||||
# add the table
|
||||
if e.args[0]==1146:
|
||||
webnotes.conn.commit()
|
||||
sql("create table `tabTag`(`name` varchar(180), tag_color varchar(180), primary key (`name`))")
|
||||
webnotes.conn.begin()
|
||||
self._add_tag_to_master(tag, color)
|
||||
|
||||
# udpate the color column
|
||||
if e.args[0]==1054:
|
||||
webnotes.conn.commit()
|
||||
sql("alter table tabTag add column tag_color varchar(180)")
|
||||
webnotes.conn.begin()
|
||||
self._add_tag_to_master(tag, color)
|
||||
|
||||
else:
|
||||
raise e
|
||||
|
||||
# --------------------------------------------------------------
|
||||
|
||||
def add_tag(self,arg):
|
||||
dt, dn, tag, color = eval(arg)
|
||||
|
||||
# create tag in tag table
|
||||
self.create_tag(tag, color)
|
||||
|
||||
# add in _user_tags
|
||||
tl = self.get_tags(dt, dn)
|
||||
|
||||
if not tag in tl:
|
||||
tl.append(tag)
|
||||
self.update_tags(dt, dn, tl)
|
||||
|
||||
return tag
|
||||
|
||||
# --------------------------------------------------------------
|
||||
|
||||
def remove_tag(self,arg):
|
||||
dt, dn, tag = eval(arg)
|
||||
tl = self.get_tags(dt, dn)
|
||||
self.update_tags(dt, dn, filter(lambda x:x!=tag, tl))
|
||||
|
||||
# --------------------------------------------------------------
|
||||
|
||||
def delete_items(self,arg):
|
||||
il = eval(arg)
|
||||
from webnotes.model import delete_doc
|
||||
for d in il:
|
||||
dt_obj = get_obj(d[0], d[1])
|
||||
if hasattr(dt_obj, 'on_trash'):
|
||||
dt_obj.on_trash()
|
||||
delete_doc(d[0], d[1])
|
||||
|
||||
# --------------------------------------------------------------
|
||||
|
||||
def archive_items(self,arg):
|
||||
arg = eval(arg)
|
||||
|
||||
from webnotes.utils.archive import archive_doc
|
||||
for d in arg['items']:
|
||||
archive_doc(d[0], d[1], arg['action']=='Restore' and 1 or 0)
|
||||
31
utilities/doctype/menu_control/menu_control.txt
Normal file
31
utilities/doctype/menu_control/menu_control.txt
Normal file
@@ -0,0 +1,31 @@
|
||||
# DocType, Menu Control
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2009-06-09 13:43:49',
|
||||
'docstatus': 0,
|
||||
'modified': '2011-01-03 12:01:42',
|
||||
'modified_by': 'sneha@webnotestech.com',
|
||||
'owner': 'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all DocType
|
||||
{
|
||||
'colour': 'White:FFF',
|
||||
'doctype': 'DocType',
|
||||
'issingle': 1,
|
||||
'module': 'Utilities',
|
||||
'name': '__common__',
|
||||
'section_style': 'Simple',
|
||||
'server_code_error': ' ',
|
||||
'show_in_menu': 0,
|
||||
'version': 38
|
||||
},
|
||||
|
||||
# DocType, Menu Control
|
||||
{
|
||||
'doctype': 'DocType',
|
||||
'name': 'Menu Control'
|
||||
}
|
||||
]
|
||||
0
utilities/doctype/patch_util/__init__.py
Normal file
0
utilities/doctype/patch_util/__init__.py
Normal file
101
utilities/doctype/patch_util/patch_util.py
Normal file
101
utilities/doctype/patch_util/patch_util.py
Normal file
@@ -0,0 +1,101 @@
|
||||
# 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 get_field_id(self, doctype, fieldname):
|
||||
f = sql("select name, idx from tabDocField where parent=%s and fieldname=%s", (doctype, fieldname))
|
||||
if not f:
|
||||
f=sql("select name, idx from tabDocField where parent=%s and label=%s", (doctype, fieldname))
|
||||
if not f:
|
||||
return '__notfound__', 0
|
||||
#msgprint("No field found for %s" % fieldname)
|
||||
#raise Exception
|
||||
return f[0]
|
||||
|
||||
def set_field_property(self, doctype, fieldname, property, value):
|
||||
f = self.get_field_id(doctype, fieldname)
|
||||
sql("update tabDocField set `%s`=%s where name=%s" % (property,'%s','%s'), (value, f[0]))
|
||||
|
||||
def move_field(self, doctype, fieldname, before_field='', after_field=''):
|
||||
f1 = self.get_field_id(doctype, fieldname)
|
||||
|
||||
# get new id
|
||||
new_idx = self.get_field_id(doctype, before_field or after_field)[1]
|
||||
if after_field:
|
||||
new_idx = new_idx + 1
|
||||
|
||||
# push fields down at new idx
|
||||
sql("update tabDocField set idx=idx+1 where idx>=%s and parent=%s", (new_idx, doctype))
|
||||
|
||||
# push fields up at old idx
|
||||
sql("update tabDocField set idx=idx-1 where idx>%s and parent=%s", (f1[1], doctype))
|
||||
|
||||
# set field idx
|
||||
sql("update tabDocField set idx=%s where name=%s", (new_idx, f1[0]))
|
||||
|
||||
def delete_field(self, doctype, fieldname):
|
||||
sql("delete from tabDocField where name=%s limit 1", self.get_field_id(doctype, fieldname)[0])
|
||||
|
||||
def delete_unnamed_field(self, doctype, after_field=''):
|
||||
f1 = self.get_field_id(doctype, after_field)
|
||||
|
||||
if f1[0]=='__notfound__':
|
||||
return
|
||||
|
||||
# check if truly un-named
|
||||
f2 = sql("select name, fieldname, label from tabDocField where idx=%s and parent=%s limit 1", (f1[1]+1, doctype))
|
||||
|
||||
if not f2:
|
||||
return
|
||||
f2 = f2[0]
|
||||
|
||||
if f2[1] or f2[2]:
|
||||
return
|
||||
else:
|
||||
sql("delete from tabDocField where name=%s limit 1", (f2[0]))
|
||||
|
||||
# move fields up
|
||||
sql("update tabDocField set idx=idx-1 where idx>%s and parent=%s", (f1[1], doctype))
|
||||
|
||||
def add_permission(self, doctype, role, level=0, read=0, write=0, create=0, submit=0, cancel=0, amend=0, match=''):
|
||||
# check if exists
|
||||
pid = sql("select name from tabDocPerm where parent=%s and role=%s and permlevel=%s", (doctype, role, level))
|
||||
if pid:
|
||||
d = Document('DocPerm', pid[0][0])
|
||||
else:
|
||||
d = Document('DocPerm')
|
||||
d.parent = doctype
|
||||
d.parenttype = 'DocType'
|
||||
d.parentfield = 'permissions'
|
||||
|
||||
d.role = role
|
||||
d.read = read
|
||||
d.write = write
|
||||
d.create = create
|
||||
d.submit = submit
|
||||
d.cancel = cancel
|
||||
d.amend = amend
|
||||
d.match = match
|
||||
|
||||
d.save(new = (not d.name and 1 or 0))
|
||||
|
||||
def delete_permission(self, doctype, role, level):
|
||||
sql("delete from `tabDocPerm` where role = '%s' and parent = '%s' and permlevel = '%s'" % (role, doctype, level))
|
||||
30
utilities/doctype/patch_util/patch_util.txt
Normal file
30
utilities/doctype/patch_util/patch_util.txt
Normal file
@@ -0,0 +1,30 @@
|
||||
# DocType, Patch Util
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2010-10-27 14:33:29',
|
||||
'docstatus': 0,
|
||||
'modified': '2010-12-21 10:19:44',
|
||||
'modified_by': 'sneha@webnotestech.com',
|
||||
'owner': 'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all DocType
|
||||
{
|
||||
'colour': 'White:FFF',
|
||||
'doctype': 'DocType',
|
||||
'issingle': 1,
|
||||
'module': 'Utilities',
|
||||
'name': '__common__',
|
||||
'section_style': 'Simple',
|
||||
'server_code_error': ' ',
|
||||
'version': 5
|
||||
},
|
||||
|
||||
# DocType, Patch Util
|
||||
{
|
||||
'doctype': 'DocType',
|
||||
'name': 'Patch Util'
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1,71 @@
|
||||
// Global dictionary of next steps for doctypes
|
||||
// ============================================
|
||||
pscript.tip_prod_dict = {'Production Order':['Material Transfer', 'Backflush']};
|
||||
|
||||
|
||||
// Set tips depending on conditions
|
||||
// ================================
|
||||
cur_frm.cscript.get_tips = function(doc, cdt, cdn){
|
||||
var next_step_list = pscript.tip_prod_dict[cur_frm.doctype] ? pscript.tip_prod_dict[cur_frm.doctype] : 0;
|
||||
|
||||
if(cur_frm.doctype!='Production Planning Tool'){
|
||||
// new doc
|
||||
if(doc.__islocal){
|
||||
if(doc.status=='Cancelled' || doc.amended_from)
|
||||
cur_frm.set_tip("You can now make changes in this " + cur_frm.doctype + " and save it by clicking on the <div style='font-weight:bold; display:inline'>Save</div> button in the above toolbar.");
|
||||
else{
|
||||
cur_frm.set_tip("To create " + cur_frm.doctype + " please start by entering all the mandatory fields (marked <div style='color:Red; display:inline'> Red</div>).");
|
||||
if(cur_frm.doctype=='Stock Entry') cur_frm.append_tip("If your purpose is Production Order, please go to <div style='font-weight:bold; display:inline'>Items</div> tab and click <div style='font-weight:bold; display:inline'>Get Items</div> to fetch the items.");
|
||||
cur_frm.append_tip("You can then save this form by clicking on the <div style='font-weight:bold; display:inline'>Save</div> button in the above toolbar.");
|
||||
}
|
||||
}
|
||||
|
||||
// doc exists
|
||||
else if(!doc.__islocal){
|
||||
// execute when doc is saved
|
||||
if(doc.docstatus==0 && cur_frm.doctype!='Production Planning Tool')
|
||||
cur_frm.set_tip("You have saved your " + cur_frm.doctype + ". You can make this draft permanent by clicking on <div style='font-weight:bold; display:inline'>Submit</div> button above.");
|
||||
|
||||
// execute if doc is submitted
|
||||
else if(doc.docstatus==1){
|
||||
cur_frm.set_tip("You have submitted this " + cur_frm.doctype + ".");
|
||||
for(var i=0; i<next_step_list.length; i++){
|
||||
if(i==0) cur_frm.append_tip("To proceed select the <div style='font-weight:bold; display:inline'>Next Steps</div> tab below. To transfer raw materials to Finished Goods Warehouse click on <div style='font-weight:bold; display:inline'>" + next_step_list[i] +"</div>.");
|
||||
else cur_frm.append_tip("To update the quantity of finished goods and raw materials in their respective warehouses click on <div style='font-weight:bold; display:inline'>" + next_step_list[i] + "</div>.");
|
||||
}
|
||||
cur_frm.append_tip("(To amend this "+ cur_frm.doctype + " click on the <div style='font-weight:bold; display:inline'>Cancel</div> button above.)");
|
||||
}
|
||||
|
||||
// execute when doc is amended
|
||||
else if(doc.docstatus==2){
|
||||
cur_frm.set_tip("To make this " + cur_frm.doctype + " editable click on the <div style='font-weight:bold; display:inline'>Amend</div> button above.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Execute if current doctype is Production Planning Tool
|
||||
// ======================================================
|
||||
cur_frm.cscript.get_PPT_tips = function(doc, cdt, cdn)
|
||||
{
|
||||
cur_frm.set_tip('Welcome to Production Planning Wizard. This helps you to raise production order and see your raw material status as you plan your production.');
|
||||
cur_frm.append_tip("To start fetch all open Production Orders and Sales Orders by clicking on the <div style='font-weight:bold; display:inline'>Get Open Documents</div> button in the <div style='font-weight:bold; display:inline'>Against Document</div> tab below");
|
||||
|
||||
cur_frm.cscript['Get Open Documents'] = function(doc, cdt, cdn){
|
||||
cur_frm.set_tip("To include the required orders in the Production Plan check mark the <div style='font-weight:bold; display:inline'>Include In Plan</div> cell below.");
|
||||
cur_frm.append_tip("Next you can go to the <div style='font-weight:bold; display:inline'>Items</div> tab and click on <div style='font-weight:bold; display:inline'>Get Items</div> button to fetch the items of the selected orders.");
|
||||
}
|
||||
|
||||
cur_frm.cscript['Get Items'] = function(doc, cdt, cdn){
|
||||
cur_frm.set_tip("Now to raise a Production Order just click on <div style='font-weight:bold; display:inline'>Raise Production Ordre</div> button below the table.");
|
||||
cur_frm.append_tip("In order to see the Raw Material Report click on <div style='font-weight:bold; display:inline'>Get Raw Material Report</div> button below the table.");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Executes when doc is edit status of doc is changed
|
||||
// ==================================================
|
||||
cur_frm.cscript.edit_status_changed = function(doc, cdt, cdn){
|
||||
cur_frm.cscript.get_tips();
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
# DocType, Production Tips Common
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2010-08-08 17:09:14',
|
||||
'docstatus': 0,
|
||||
'modified': '2010-09-20 14:06:57',
|
||||
'modified_by': 'Administrator',
|
||||
'owner': 'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all DocType
|
||||
{
|
||||
'colour': 'White:FFF',
|
||||
'doctype': 'DocType',
|
||||
'issingle': 1,
|
||||
'module': 'Utilities',
|
||||
'name': '__common__',
|
||||
'section_style': 'Simple',
|
||||
'server_code_error': ' ',
|
||||
'version': 37
|
||||
},
|
||||
|
||||
# DocType, Production Tips Common
|
||||
{
|
||||
'doctype': 'DocType',
|
||||
'name': 'Production Tips Common'
|
||||
}
|
||||
]
|
||||
0
utilities/doctype/profile_control/__init__.py
Normal file
0
utilities/doctype/profile_control/__init__.py
Normal file
187
utilities/doctype/profile_control/profile_control.py
Normal file
187
utilities/doctype/profile_control/profile_control.py
Normal file
@@ -0,0 +1,187 @@
|
||||
# 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
|
||||
self.last_profile = None
|
||||
|
||||
# Sync Profile with Gateway
|
||||
# -------------------------
|
||||
def sync_with_gateway(self,pid):
|
||||
p = Document('Profile',pid)
|
||||
|
||||
# login to gateway
|
||||
from webnotes.utils.webservice import FrameworkServer
|
||||
fw = FrameworkServer('www.erpnext.com','/','__system@webnotestech.com','password',https=1)
|
||||
|
||||
account_id = sql("select value from tabSingles where doctype='Control Panel' and field='account_id'")[0][0]
|
||||
|
||||
# call add profile
|
||||
ret = fw.runserverobj('Profile Control','Profile Control','add_profile_gateway',str([p.first_name, p.middle_name, p.last_name, p.email, p.name, account_id]))
|
||||
|
||||
if ret.get('exc'):
|
||||
msgprint(ret['exc'])
|
||||
raise Exception
|
||||
|
||||
def get_role_permission(self,role):
|
||||
perm = sql("select distinct t1.`parent`, t1.`read`, t1.`write`, t1.`create`, t1.`submit`,t1.`cancel`,t1.`amend` from `tabDocPerm` t1, `tabDocType` t2 where t1.`role` ='%s' and t1.docstatus !=2 and t1.permlevel = 0 and t1.`read` = 1 and t2.module != 'Recycle Bin' and t1.parent=t2.name "%role)
|
||||
return perm or ''
|
||||
|
||||
|
||||
# Check if password is expired
|
||||
# --------------------------------
|
||||
def has_pwd_expired(self):
|
||||
if session['user'] != 'Administrator' and session['user'].lower() != 'demo':
|
||||
last_pwd_date = None
|
||||
try:
|
||||
last_pwd_date = sql("select password_last_updated from tabProfile where name=%s",session['user'])[0][0] or ''
|
||||
except:
|
||||
return 'No'
|
||||
if cstr(last_pwd_date) == '':
|
||||
sql("update tabProfile set password_last_updated = '%s' where name='%s'"% (nowdate(),session['user']))
|
||||
return 'No'
|
||||
else:
|
||||
date_diff = (getdate(nowdate()) - last_pwd_date).days
|
||||
expiry_period = sql("select value from tabSingles where doctype='Control Panel' and field='password_expiry_days'")
|
||||
if expiry_period and cint(expiry_period[0][0]) and cint(expiry_period[0][0]) < date_diff:
|
||||
return 'Yes'
|
||||
return 'No'
|
||||
|
||||
def reset_password(self,pwd):
|
||||
if sql("select name from tabProfile where password=PASSWORD(%s) and name=%s", (pwd,session['user'])):
|
||||
return 'Password cannot be same as old password'
|
||||
sql("update tabProfile set password=PASSWORD(%s),password_last_updated=%s where name = %s", (pwd,nowdate(),session['user']))
|
||||
return 'ok'
|
||||
|
||||
#-------------------------------------------------------------------------------------------------------
|
||||
#functions for manage user page
|
||||
#-----------Enable/Disable Profile-----------------------------------------------------------------------------------------------
|
||||
def change_login(self,args):
|
||||
args = eval(args)
|
||||
|
||||
if cint(args['set_disabled'])==0:
|
||||
sql("update `tabProfile` set enabled=1 where name='%s'"%args['user'])
|
||||
else:
|
||||
sql("update `tabProfile` set enabled=0 where name='%s'"%args['user'])
|
||||
|
||||
return 'ok'
|
||||
|
||||
#------------return role list -------------------------------------------------------------------------------------------------
|
||||
# All roles of Role Master
|
||||
def get_role(self):
|
||||
r_list=sql("select name from `tabRole` where name not in ('Administrator','All','Guest')")
|
||||
if r_list[0][0]:
|
||||
r_list = [x[0] for x in r_list]
|
||||
return r_list
|
||||
|
||||
# Only user specific role
|
||||
def get_user_role(self,usr):
|
||||
r_list=sql("select role from `tabUserRole` where parent=%s and role not in ('Administrator','All','Guest')",usr)
|
||||
if r_list[0][0]:
|
||||
r_list = [x[0] for x in r_list]
|
||||
else:
|
||||
r_list=[]
|
||||
return r_list
|
||||
|
||||
# adding new role
|
||||
def add_user_role(self,args):
|
||||
arg=eval(args)
|
||||
sql("delete from `tabUserRole` where parenttype='Profile' and parent ='%s'" % (cstr(arg['user'])))
|
||||
role_list = arg['role_list'].split(',')
|
||||
for r in role_list:
|
||||
pr=Document('UserRole')
|
||||
pr.parent = arg['user']
|
||||
pr.parenttype = 'Profile'
|
||||
pr.role = r
|
||||
pr.parentfield = 'userroles'
|
||||
pr.save(1)
|
||||
|
||||
|
||||
|
||||
# Add new member
|
||||
# ---------------
|
||||
def add_profile(self,arg):
|
||||
|
||||
# Check credit balance
|
||||
get_obj('WN ERP Client Control').check_credit_balance()
|
||||
|
||||
arg=eval(arg)
|
||||
pr=Document('Profile')
|
||||
for d in arg.keys():
|
||||
if d!='role':
|
||||
pr.fields[d] = arg[d]
|
||||
|
||||
pr.enabled=0
|
||||
pr.user_type='System User'
|
||||
pr.save(1)
|
||||
pr_obj = get_obj('Profile',pr.name)
|
||||
if (pr.name):
|
||||
msg="New member is added"
|
||||
pr_obj.on_update()
|
||||
else:
|
||||
msg="Profile not created"
|
||||
|
||||
return cstr(msg)
|
||||
|
||||
# to find currently login user
|
||||
def current_login(self):
|
||||
cl_list=sql("select distinct user from tabSessions")
|
||||
if cl_list:
|
||||
cl_list=[x[0] for x in cl_list]
|
||||
|
||||
return cl_list
|
||||
|
||||
|
||||
# Remove Profile
|
||||
# ---------------
|
||||
def remove_profile(self, user):
|
||||
# delete profile
|
||||
webnotes.model.delete_doc('Profile',user)
|
||||
|
||||
# Update WN ERP Client Control
|
||||
sql("update tabSingles set value = value - 1 where field = 'total_users' and doctype = 'WN ERP Client Control'")
|
||||
|
||||
# login to gateway
|
||||
from webnotes.utils.webservice import FrameworkServer
|
||||
fw = FrameworkServer('www.erpnext.com','/','__system@webnotestech.com','password',https=1)
|
||||
|
||||
account_id = sql("select value from tabSingles where doctype='Control Panel' and field='account_id'")[0][0]
|
||||
|
||||
# call remove profile
|
||||
ret = fw.runserverobj('Profile Control','Profile Control','remove_app_sub',str([user, account_id, session['user']]))
|
||||
|
||||
if ret.get('exc'):
|
||||
msgprint(ret['exc'])
|
||||
raise Exception
|
||||
|
||||
return "User Removed Successfully"
|
||||
|
||||
|
||||
# Create Profile
|
||||
# ---------------
|
||||
def create_profile(self, email):
|
||||
if sql("select name from tabProfile where name = %s", email):
|
||||
sql("update tabProfile set docstatus = 0 where name = %s", email)
|
||||
else:
|
||||
pr = Document('Profile')
|
||||
pr.email = email
|
||||
pr.enabled=0
|
||||
pr.user_type='System User'
|
||||
pr.save(1)
|
||||
31
utilities/doctype/profile_control/profile_control.txt
Normal file
31
utilities/doctype/profile_control/profile_control.txt
Normal file
@@ -0,0 +1,31 @@
|
||||
# DocType, Profile Control
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2009-05-29 12:19:21',
|
||||
'docstatus': 0,
|
||||
'modified': '2010-11-03 11:03:11',
|
||||
'modified_by': 'Administrator',
|
||||
'owner': 'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all DocType
|
||||
{
|
||||
'colour': 'White:FFF',
|
||||
'doctype': 'DocType',
|
||||
'issingle': 1,
|
||||
'module': 'Utilities',
|
||||
'name': '__common__',
|
||||
'section_style': 'Simple',
|
||||
'server_code_error': ' ',
|
||||
'show_in_menu': 0,
|
||||
'version': 12
|
||||
},
|
||||
|
||||
# DocType, Profile Control
|
||||
{
|
||||
'doctype': 'DocType',
|
||||
'name': 'Profile Control'
|
||||
}
|
||||
]
|
||||
0
utilities/doctype/receiver_detail/__init__.py
Normal file
0
utilities/doctype/receiver_detail/__init__.py
Normal file
72
utilities/doctype/receiver_detail/receiver_detail.txt
Normal file
72
utilities/doctype/receiver_detail/receiver_detail.txt
Normal file
@@ -0,0 +1,72 @@
|
||||
# DocType, Receiver Detail
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2010-08-08 17:09:19',
|
||||
'docstatus': 0,
|
||||
'modified': '2010-09-20 14:06:57',
|
||||
'modified_by': 'Administrator',
|
||||
'owner': 'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all DocType
|
||||
{
|
||||
'colour': 'White:FFF',
|
||||
'doctype': 'DocType',
|
||||
'istable': 1,
|
||||
'module': 'Utilities',
|
||||
'name': '__common__',
|
||||
'section_style': 'Tray',
|
||||
'server_code_error': ' ',
|
||||
'version': 2
|
||||
},
|
||||
|
||||
# These values are common for all DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldtype': 'Data',
|
||||
'name': '__common__',
|
||||
'oldfieldtype': 'Data',
|
||||
'parent': 'Receiver Detail',
|
||||
'parentfield': 'fields',
|
||||
'parenttype': 'DocType',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocType, Receiver Detail
|
||||
{
|
||||
'doctype': 'DocType',
|
||||
'name': 'Receiver Detail'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'customer_name',
|
||||
'idx': 1,
|
||||
'label': 'Customer Name',
|
||||
'oldfieldname': 'customer_name'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'receiver_name',
|
||||
'idx': 2,
|
||||
'label': 'Receiver Name',
|
||||
'oldfieldname': 'receiver_name',
|
||||
'width': '350px'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'mobile_no',
|
||||
'idx': 3,
|
||||
'label': 'Mobile No',
|
||||
'oldfieldname': 'mobile_no',
|
||||
'reqd': 1,
|
||||
'width': '200px'
|
||||
}
|
||||
]
|
||||
0
utilities/doctype/rename_tool/__init__.py
Executable file
0
utilities/doctype/rename_tool/__init__.py
Executable file
5
utilities/doctype/rename_tool/rename_tool.js
Normal file
5
utilities/doctype/rename_tool/rename_tool.js
Normal file
@@ -0,0 +1,5 @@
|
||||
// over-ride the link query to return relevant link names
|
||||
|
||||
cur_frm.fields_dict.document_to_rename.get_query = function(doc, dt, dn) {
|
||||
return "SELECT name FROM `tab"+doc.select_doctype+"` WHERE docstatus<2 AND name LIKE '%s' LIMIT 50";
|
||||
}
|
||||
20
utilities/doctype/rename_tool/rename_tool.py
Normal file
20
utilities/doctype/rename_tool/rename_tool.py
Normal file
@@ -0,0 +1,20 @@
|
||||
class DocType:
|
||||
def __init__(self, d, dl=[]):
|
||||
self.doc, self.doclist = d, dl
|
||||
|
||||
def rename(self):
|
||||
"""
|
||||
Generate update quereies for rename
|
||||
"""
|
||||
import webnotes.model
|
||||
from webnotes.model.code import get_obj
|
||||
|
||||
# call on_rename method if exists
|
||||
obj = get_obj(self.doc.select_doctype, self.doc.document_to_rename)
|
||||
if hasattr(obj, 'on_rename'):
|
||||
obj.on_rename(self.doc.new_name)
|
||||
|
||||
# rename the document
|
||||
webnotes.model.rename(self.doc.select_doctype, self.doc.document_to_rename, self.doc.new_name)
|
||||
|
||||
webnotes.msgprint("Item renamed successfully")
|
||||
102
utilities/doctype/rename_tool/rename_tool.txt
Executable file
102
utilities/doctype/rename_tool/rename_tool.txt
Executable file
@@ -0,0 +1,102 @@
|
||||
# DocType, Rename Tool
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2011-06-23 11:03:25',
|
||||
'docstatus': 0,
|
||||
'modified': '2011-06-23 11:03:25',
|
||||
'modified_by': 'Administrator',
|
||||
'owner': 'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all DocType
|
||||
{
|
||||
'_last_update': '1308739509',
|
||||
'allow_email': 1,
|
||||
'allow_print': 1,
|
||||
'colour': 'White:FFF',
|
||||
'doctype': 'DocType',
|
||||
'hide_heading': 0,
|
||||
'hide_toolbar': 0,
|
||||
'issingle': 1,
|
||||
'module': 'Utilities',
|
||||
'name': '__common__',
|
||||
'section_style': 'Simple',
|
||||
'show_in_menu': 0,
|
||||
'version': 6
|
||||
},
|
||||
|
||||
# These values are common for all DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'name': '__common__',
|
||||
'parent': 'Rename Tool',
|
||||
'parentfield': 'fields',
|
||||
'parenttype': 'DocType',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# These values are common for all DocPerm
|
||||
{
|
||||
'create': 1,
|
||||
'doctype': 'DocPerm',
|
||||
'idx': 1,
|
||||
'name': '__common__',
|
||||
'parent': 'Rename Tool',
|
||||
'parentfield': 'permissions',
|
||||
'parenttype': 'DocType',
|
||||
'permlevel': 0,
|
||||
'read': 1,
|
||||
'role': 'System Manager',
|
||||
'write': 1
|
||||
},
|
||||
|
||||
# DocType, Rename Tool
|
||||
{
|
||||
'doctype': 'DocType',
|
||||
'name': 'Rename Tool'
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'doctype': 'DocPerm'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'select_doctype',
|
||||
'fieldtype': 'Select',
|
||||
'idx': 1,
|
||||
'label': 'Select DocType',
|
||||
'options': 'link:DocType'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'document_to_rename',
|
||||
'fieldtype': 'Link',
|
||||
'idx': 2,
|
||||
'label': 'Document to rename'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'new_name',
|
||||
'fieldtype': 'Data',
|
||||
'idx': 3,
|
||||
'label': 'New Name'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldtype': 'Button',
|
||||
'idx': 4,
|
||||
'label': 'Rename',
|
||||
'options': 'rename'
|
||||
}
|
||||
]
|
||||
0
utilities/doctype/reposting_tool/__init__.py
Normal file
0
utilities/doctype/reposting_tool/__init__.py
Normal file
63
utilities/doctype/reposting_tool/reposting_tool.js
Normal file
63
utilities/doctype/reposting_tool/reposting_tool.js
Normal file
@@ -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 ++;
|
||||
}
|
||||
183
utilities/doctype/reposting_tool/reposting_tool.py
Normal file
183
utilities/doctype/reposting_tool/reposting_tool.py
Normal file
@@ -0,0 +1,183 @@
|
||||
# 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)
|
||||
|
||||
projected_qty = flt(qty_dict['indented_qty']) + flt(qty_dict['ordered_qty']) - flt(qty_dict['reserved_qty']) + flt(qty_dict['planned_qty']) + flt(qty_dict['actual_qty'])
|
||||
# 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', projected_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']), projected_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_all_bins(self):
|
||||
bins = sql("select name from tabBin")
|
||||
cnt = 0
|
||||
for bin in bins:
|
||||
if cnt % 20 == 0:
|
||||
sql("commit")
|
||||
sql("start transaction")
|
||||
cnt += 1
|
||||
|
||||
self.repair_bin(bin[0])
|
||||
|
||||
# =============================================================================
|
||||
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(['support@iwebnotes.com'], subject='Repair of ' + cstr(subject), parts = [('text/plain', email_msg)])
|
||||
96
utilities/doctype/reposting_tool/reposting_tool.txt
Normal file
96
utilities/doctype/reposting_tool/reposting_tool.txt
Normal file
@@ -0,0 +1,96 @@
|
||||
# DocType, Reposting Tool
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2010-08-08 17:09:19',
|
||||
'docstatus': 0,
|
||||
'modified': '2011-04-19 11:50:09',
|
||||
'modified_by': 'Administrator',
|
||||
'owner': 'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all DocType
|
||||
{
|
||||
'_last_update': '1308741898',
|
||||
'allow_copy': 1,
|
||||
'allow_email': 1,
|
||||
'allow_print': 1,
|
||||
'colour': 'Light Blue:DEF',
|
||||
'doctype': 'DocType',
|
||||
'hide_toolbar': 1,
|
||||
'in_create': 0,
|
||||
'issingle': 1,
|
||||
'module': 'Utilities',
|
||||
'name': '__common__',
|
||||
'read_only': 1,
|
||||
'section_style': 'Simple',
|
||||
'server_code_error': ' ',
|
||||
'show_in_menu': 1,
|
||||
'version': 174
|
||||
},
|
||||
|
||||
# These values are common for all DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'name': '__common__',
|
||||
'parent': 'Reposting Tool',
|
||||
'parentfield': 'fields',
|
||||
'parenttype': 'DocType',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# These values are common for all DocPerm
|
||||
{
|
||||
'create': 1,
|
||||
'doctype': 'DocPerm',
|
||||
'idx': 1,
|
||||
'name': '__common__',
|
||||
'parent': 'Reposting Tool',
|
||||
'parentfield': 'permissions',
|
||||
'parenttype': 'DocType',
|
||||
'permlevel': 0,
|
||||
'read': 1,
|
||||
'role': 'System Manager',
|
||||
'write': 1
|
||||
},
|
||||
|
||||
# DocType, Reposting Tool
|
||||
{
|
||||
'doctype': 'DocType',
|
||||
'name': 'Reposting Tool'
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'doctype': 'DocPerm'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'recalculate_mar_&_actual_qty',
|
||||
'fieldtype': 'Data',
|
||||
'idx': 1,
|
||||
'label': 'Recalculate MAR & Actual Qty'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': 'White:FFF',
|
||||
'doctype': 'DocField',
|
||||
'fieldtype': 'Button',
|
||||
'idx': 2,
|
||||
'label': 'Repost Bin',
|
||||
'trigger': 'Client'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldtype': 'Button',
|
||||
'idx': 3,
|
||||
'label': 'Repost Account Balances',
|
||||
'trigger': 'Client'
|
||||
}
|
||||
]
|
||||
0
utilities/doctype/sms_center/__init__.py
Normal file
0
utilities/doctype/sms_center/__init__.py
Normal file
8
utilities/doctype/sms_center/sms_center.js
Normal file
8
utilities/doctype/sms_center/sms_center.js
Normal file
@@ -0,0 +1,8 @@
|
||||
cur_frm.cscript.refresh = function(doc, cdt, cdn) {
|
||||
if(doc.send_to == 'Customer Group')
|
||||
unhide_field('customer_group_name');
|
||||
else
|
||||
hide_field('customer_group_name');
|
||||
}
|
||||
|
||||
cur_frm.cscript.send_to = cur_frm.cscript.refresh;
|
||||
59
utilities/doctype/sms_center/sms_center.py
Normal file
59
utilities/doctype/sms_center/sms_center.py
Normal file
@@ -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, doc, doclist=[]):
|
||||
self.doc = doc
|
||||
self.doclist = doclist
|
||||
|
||||
def create_receiver_table(self):
|
||||
if self.doc.send_to:
|
||||
self.doc.clear_table(self.doclist, 'receiver_details')
|
||||
rec = ''
|
||||
if self.doc.send_to == 'All Customer':
|
||||
rec = sql("select customer_name, CONCAT(ifnull(first_name,''),'',ifnull(last_name,'')), mobile_no from `tabContact` where ifnull(customer_name,'') !='' and ifnull(mobile_no,'')!=''")
|
||||
|
||||
elif self.doc.send_to == 'Customer Group' and self.doc.customer_group_name:
|
||||
|
||||
rec = sql("select t2.customer_name, CONCAT(ifnull(first_name,''),'',ifnull(last_name,'')), t1.mobile_no from `tabContact` t1, `tabCustomer` t2 where t2.name = t1.customer_name and ifnull(t1.mobile_no,'')!='' and t2.customer_group = '%s'"%self.doc.customer_group_name)
|
||||
if not rec:
|
||||
msgprint("Either customer having no contact or customer's contact does not have mobile no")
|
||||
raise Exception
|
||||
|
||||
for d in rec:
|
||||
ch = addchild(self.doc, 'receiver_details', 'Receiver Detail', 1, self.doclist)
|
||||
ch.customer_name = d[0]
|
||||
ch.receiver_name = d[1]
|
||||
ch.mobile_no = d[2]
|
||||
else:
|
||||
msgprint("Please select 'Send To' field")
|
||||
|
||||
|
||||
def send_sms(self):
|
||||
if not self.doc.message:
|
||||
msgprint("Please type the message before sending")
|
||||
elif not getlist(self.doclist, 'receiver_details'):
|
||||
msgprint("Receiver Table is blank.")
|
||||
else:
|
||||
receiver_list = []
|
||||
for d in getlist(self.doclist, 'receiver_details'):
|
||||
if d.mobile_no:
|
||||
receiver_list.append(d.mobile_no)
|
||||
if receiver_list:
|
||||
msgprint(get_obj('SMS Control', 'SMS Control').send_sms(receiver_list, self.doc.message))
|
||||
1
utilities/doctype/sms_center/sms_center.txt
Normal file
1
utilities/doctype/sms_center/sms_center.txt
Normal file
File diff suppressed because one or more lines are too long
0
utilities/doctype/sms_control/__init__.py
Normal file
0
utilities/doctype/sms_control/__init__.py
Normal file
93
utilities/doctype/sms_control/sms_control.js
Normal file
93
utilities/doctype/sms_control/sms_control.js
Normal file
@@ -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]);
|
||||
}
|
||||
190
utilities/doctype/sms_control/sms_control.py
Normal file
190
utilities/doctype/sms_control/sms_control.py
Normal file
@@ -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")
|
||||
59
utilities/doctype/sms_control/sms_control.txt
Normal file
59
utilities/doctype/sms_control/sms_control.txt
Normal file
@@ -0,0 +1,59 @@
|
||||
# DocType, SMS Control
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2010-08-08 17:09:24',
|
||||
'docstatus': 0,
|
||||
'modified': '2011-01-11 18:40:35',
|
||||
'modified_by': 'Administrator',
|
||||
'owner': 'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all DocType
|
||||
{
|
||||
'colour': 'White:FFF',
|
||||
'doctype': 'DocType',
|
||||
'in_create': 0,
|
||||
'issingle': 1,
|
||||
'module': 'Utilities',
|
||||
'name': '__common__',
|
||||
'section_style': 'Simple',
|
||||
'server_code_error': ' ',
|
||||
'show_in_menu': 0,
|
||||
'version': 8
|
||||
},
|
||||
|
||||
# These values are common for all DocPerm
|
||||
{
|
||||
'doctype': 'DocPerm',
|
||||
'name': '__common__',
|
||||
'parent': 'SMS Control',
|
||||
'parentfield': 'permissions',
|
||||
'parenttype': 'DocType',
|
||||
'read': 1,
|
||||
'role': 'System Manager'
|
||||
},
|
||||
|
||||
# DocType, SMS Control
|
||||
{
|
||||
'doctype': 'DocType',
|
||||
'name': 'SMS Control'
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'create': 1,
|
||||
'doctype': 'DocPerm',
|
||||
'idx': 1,
|
||||
'permlevel': 0,
|
||||
'write': 1
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'doctype': 'DocPerm',
|
||||
'idx': 2,
|
||||
'permlevel': 1
|
||||
}
|
||||
]
|
||||
0
utilities/doctype/sms_log/__init__.py
Normal file
0
utilities/doctype/sms_log/__init__.py
Normal file
130
utilities/doctype/sms_log/sms_log.txt
Normal file
130
utilities/doctype/sms_log/sms_log.txt
Normal file
@@ -0,0 +1,130 @@
|
||||
# DocType, SMS Log
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2011-01-11 13:00:09',
|
||||
'docstatus': 0,
|
||||
'modified': '2011-01-11 12:51:46',
|
||||
'modified_by': 'Administrator',
|
||||
'owner': 'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all DocType
|
||||
{
|
||||
'autoname': 'SMSLOG/.########',
|
||||
'colour': 'White:FFF',
|
||||
'doctype': 'DocType',
|
||||
'module': 'Utilities',
|
||||
'name': '__common__',
|
||||
'section_style': 'Simple',
|
||||
'show_in_menu': 0,
|
||||
'version': 3
|
||||
},
|
||||
|
||||
# These values are common for all DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'name': '__common__',
|
||||
'parent': 'SMS Log',
|
||||
'parentfield': 'fields',
|
||||
'parenttype': 'DocType',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# These values are common for all DocPerm
|
||||
{
|
||||
'create': 1,
|
||||
'doctype': 'DocPerm',
|
||||
'idx': 1,
|
||||
'name': '__common__',
|
||||
'parent': 'SMS Log',
|
||||
'parentfield': 'permissions',
|
||||
'parenttype': 'DocType',
|
||||
'permlevel': 0,
|
||||
'read': 1,
|
||||
'role': 'System Manager',
|
||||
'write': 1
|
||||
},
|
||||
|
||||
# DocType, SMS Log
|
||||
{
|
||||
'doctype': 'DocType',
|
||||
'name': 'SMS Log'
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'doctype': 'DocPerm'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldtype': 'Column Break',
|
||||
'idx': 1,
|
||||
'width': '50%'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'sender_name',
|
||||
'fieldtype': 'Data',
|
||||
'idx': 2,
|
||||
'label': 'Sender Name'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'sent_on',
|
||||
'fieldtype': 'Date',
|
||||
'idx': 3,
|
||||
'label': 'Sent On'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'receiver_list',
|
||||
'fieldtype': 'Small Text',
|
||||
'idx': 4,
|
||||
'label': 'Receiver List'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldtype': 'Column Break',
|
||||
'idx': 5,
|
||||
'width': '50%'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'no_of_requested_sms',
|
||||
'fieldtype': 'Int',
|
||||
'idx': 6,
|
||||
'label': 'No of Requested SMS'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'no_of_sent_sms',
|
||||
'fieldtype': 'Int',
|
||||
'idx': 7,
|
||||
'label': 'No of Sent SMS'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'message',
|
||||
'fieldtype': 'Small Text',
|
||||
'idx': 8,
|
||||
'label': 'Message'
|
||||
}
|
||||
]
|
||||
0
utilities/doctype/sso_control/__init__.py
Normal file
0
utilities/doctype/sso_control/__init__.py
Normal file
30
utilities/doctype/sso_control/sso_control.py
Normal file
30
utilities/doctype/sso_control/sso_control.py
Normal file
@@ -0,0 +1,30 @@
|
||||
# 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 logout_sso(self):
|
||||
import webnotes
|
||||
import webnotes.utils.webservice
|
||||
|
||||
if session['data'].get('login_from'):
|
||||
sso = webnotes.utils.webservice.FrameworkServer(session['data'].get('login_from'), '/', '__system@webnotestech.com', 'password')
|
||||
sso.runserverobj('SSO Control', 'SSO Control', 'logout_user', session['user'])
|
||||
30
utilities/doctype/sso_control/sso_control.txt
Normal file
30
utilities/doctype/sso_control/sso_control.txt
Normal file
@@ -0,0 +1,30 @@
|
||||
# DocType, SSO Control
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2010-08-08 17:09:24',
|
||||
'docstatus': 0,
|
||||
'modified': '2010-12-20 19:44:29',
|
||||
'modified_by': 'umair@iwebnotes.com',
|
||||
'owner': 'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all DocType
|
||||
{
|
||||
'colour': 'White:FFF',
|
||||
'doctype': 'DocType',
|
||||
'issingle': 1,
|
||||
'module': 'Utilities',
|
||||
'name': '__common__',
|
||||
'section_style': 'Simple',
|
||||
'server_code_error': ' ',
|
||||
'version': 1
|
||||
},
|
||||
|
||||
# DocType, SSO Control
|
||||
{
|
||||
'doctype': 'DocType',
|
||||
'name': 'SSO Control'
|
||||
}
|
||||
]
|
||||
0
utilities/doctype/todo_item/__init__.py
Normal file
0
utilities/doctype/todo_item/__init__.py
Normal file
142
utilities/doctype/todo_item/todo_item.txt
Normal file
142
utilities/doctype/todo_item/todo_item.txt
Normal file
@@ -0,0 +1,142 @@
|
||||
# DocType, ToDo Item
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2009-05-12 11:19:11',
|
||||
'docstatus': 0,
|
||||
'modified': '2010-09-20 14:06:57',
|
||||
'modified_by': 'yogesh@webnotestech.com',
|
||||
'owner': 'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all DocType
|
||||
{
|
||||
'autoname': 'TDI.########',
|
||||
'colour': 'White:FFF',
|
||||
'doctype': 'DocType',
|
||||
'in_create': 1,
|
||||
'module': 'Utilities',
|
||||
'name': '__common__',
|
||||
'read_only': 1,
|
||||
'section_style': 'Simple',
|
||||
'server_code_error': ' ',
|
||||
'show_in_menu': 0
|
||||
},
|
||||
|
||||
# These values are common for all DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'name': '__common__',
|
||||
'parent': 'ToDo Item',
|
||||
'parentfield': 'fields',
|
||||
'parenttype': 'DocType',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# These values are common for all DocPerm
|
||||
{
|
||||
'create': 1,
|
||||
'doctype': 'DocPerm',
|
||||
'idx': 1,
|
||||
'name': '__common__',
|
||||
'parent': 'ToDo Item',
|
||||
'parentfield': 'permissions',
|
||||
'parenttype': 'DocType',
|
||||
'permlevel': 0,
|
||||
'read': 1,
|
||||
'role': 'All'
|
||||
},
|
||||
|
||||
# DocType, ToDo Item
|
||||
{
|
||||
'doctype': 'DocType',
|
||||
'name': 'ToDo Item'
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'doctype': 'DocPerm'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'description',
|
||||
'fieldtype': 'Text',
|
||||
'idx': 1,
|
||||
'label': 'Description',
|
||||
'oldfieldname': 'description',
|
||||
'oldfieldtype': 'Text',
|
||||
'width': '300px'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'date',
|
||||
'fieldtype': 'Date',
|
||||
'idx': 2,
|
||||
'label': 'Date',
|
||||
'oldfieldname': 'date',
|
||||
'oldfieldtype': 'Date',
|
||||
'reqd': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'priority',
|
||||
'fieldtype': 'Data',
|
||||
'idx': 3,
|
||||
'label': 'Priority',
|
||||
'oldfieldname': 'priority',
|
||||
'oldfieldtype': 'Data',
|
||||
'reqd': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'reference_type',
|
||||
'fieldtype': 'Data',
|
||||
'idx': 4,
|
||||
'label': 'Reference Type',
|
||||
'oldfieldname': 'reference_type',
|
||||
'oldfieldtype': 'Data'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'reference_name',
|
||||
'fieldtype': 'Data',
|
||||
'idx': 5,
|
||||
'label': 'Reference Name',
|
||||
'oldfieldname': 'reference_name',
|
||||
'oldfieldtype': 'Data'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'checked',
|
||||
'fieldtype': 'Check',
|
||||
'idx': 6,
|
||||
'label': 'Checked',
|
||||
'oldfieldname': 'checked',
|
||||
'oldfieldtype': 'Check'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'role',
|
||||
'fieldtype': 'Link',
|
||||
'idx': 7,
|
||||
'label': 'Role',
|
||||
'oldfieldname': 'role',
|
||||
'oldfieldtype': 'Link',
|
||||
'options': 'Role'
|
||||
}
|
||||
]
|
||||
0
utilities/doctype/trash_control/__init__.py
Normal file
0
utilities/doctype/trash_control/__init__.py
Normal file
59
utilities/doctype/trash_control/trash_control.py
Normal file
59
utilities/doctype/trash_control/trash_control.py
Normal file
@@ -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()
|
||||
32
utilities/doctype/trash_control/trash_control.txt
Normal file
32
utilities/doctype/trash_control/trash_control.txt
Normal file
@@ -0,0 +1,32 @@
|
||||
# DocType, Trash Control
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2010-08-08 17:09:29',
|
||||
'docstatus': 0,
|
||||
'modified': '2010-12-30 11:44:36',
|
||||
'modified_by': 'umair@iwebnotes.com',
|
||||
'owner': 'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all DocType
|
||||
{
|
||||
'colour': 'White:FFF',
|
||||
'doctype': 'DocType',
|
||||
'in_create': 1,
|
||||
'issingle': 1,
|
||||
'module': 'Utilities',
|
||||
'name': '__common__',
|
||||
'read_only': 1,
|
||||
'section_style': 'Simple',
|
||||
'server_code_error': ' ',
|
||||
'version': 35
|
||||
},
|
||||
|
||||
# DocType, Trash Control
|
||||
{
|
||||
'doctype': 'DocType',
|
||||
'name': 'Trash Control'
|
||||
}
|
||||
]
|
||||
0
utilities/doctype/wn_erp_client_control/__init__.py
Normal file
0
utilities/doctype/wn_erp_client_control/__init__.py
Normal file
141
utilities/doctype/wn_erp_client_control/wn_erp_client_control.py
Normal file
141
utilities/doctype/wn_erp_client_control/wn_erp_client_control.py
Normal file
@@ -0,0 +1,141 @@
|
||||
# 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, self.doclist = doc, doclist
|
||||
|
||||
|
||||
# Check End of Trial Period
|
||||
# -------------------------
|
||||
def trial_payment_reminders(self):
|
||||
if cint(self.doc.is_trial_account)==1:
|
||||
# Trial Period Expiry
|
||||
trial_end_date = add_days(self.doc.account_start_date, 30)
|
||||
days = date_diff(trial_end_date, nowdate())
|
||||
# check if trial period has expired
|
||||
if days < 10 and days >= 0 and has_common(['System Manager'],webnotes.user.get_roles()):
|
||||
return "Your Trial Period expires on '%s'. Please buy credits online using Manage Account." % (formatdate(trial_end_date))
|
||||
|
||||
# trial period has already expired
|
||||
elif days < 0 and days >= -6:
|
||||
extended_days = 7 + days
|
||||
return "Your Trial Period has expired on %s. However, your account will be live for %s days. Please contact your System Manager to buy credits." % (formatdate(trial_end_date),cstr(extended_days))
|
||||
elif not has_common(['Administrator'],webnotes.user.get_roles()) and days < -6:
|
||||
return "Stopped"
|
||||
|
||||
# Account is not a trial account
|
||||
else:
|
||||
return self.account_expiry_reminder()
|
||||
|
||||
|
||||
# Account Expiry Reminder
|
||||
# -----------------------
|
||||
def account_expiry_reminder(self):
|
||||
import webnotes.utils
|
||||
from datetime import datetime
|
||||
# Payment Reminder in case of not enough balance
|
||||
cr_reqd = cint(self.doc.total_users)
|
||||
days_left = cint(self.calc_days())
|
||||
# check if account balance is sufficient
|
||||
if cint(self.doc.credit_balance)<(cr_reqd):
|
||||
|
||||
# Difference between last payment date and current date
|
||||
if self.doc.last_deduction_date: last_payment = date_diff(nowdate(),self.doc.last_deduction_date)
|
||||
else: last_payment = -1
|
||||
|
||||
# 7 days extension
|
||||
remaining_days = days_left - 24
|
||||
if last_payment > 30 or last_payment == -1:
|
||||
if remaining_days < 8 and remaining_days >= 1:
|
||||
return "Your account will be de-activated in " + cstr(remaining_days) + " days. Please contact your System Manager to buy credits."
|
||||
elif remaining_days==0:
|
||||
return "Your account will be disabled from tomorrow. Please contact your System Manager to buy credits."
|
||||
elif not has_common(['Administrator'],webnotes.user.get_roles()):
|
||||
return "Stopped"
|
||||
|
||||
# check if user account is extended for seven days
|
||||
if cint(self.doc.is_trial_account)==0:
|
||||
if days_left < 10 and days_left >= 0:
|
||||
return "You have only %s Credits in your account. Buy credits before %s." % (cint(self.doc.credit_balance),formatdate(self.next_bill_sdate))
|
||||
|
||||
|
||||
|
||||
# Calculate days between current date and billing cycle end date
|
||||
# --------------------------------------------------------------
|
||||
def calc_days(self):
|
||||
if self.doc.billing_cycle_date:
|
||||
next_bill_month = cint(nowdate().split('-')[1])
|
||||
if cint(nowdate().split('-')[2]) > cint(self.doc.billing_cycle_date.split('-')[2]):
|
||||
next_bill_month = cint(nowdate().split('-')[1]) + 1
|
||||
next_bill_year = nowdate().split('-')[0]
|
||||
if next_bill_month > 12:
|
||||
next_bill_month = next_bill_month % 12
|
||||
next_bill_year += 1
|
||||
self.next_bill_sdate = cstr(next_bill_year)+'-'+cstr(next_bill_month)+'-'+(self.calc_next_day(next_bill_year,next_bill_month))
|
||||
#msgprint("next_bill_month :::" + self.next_bill_sdate)
|
||||
return date_diff(self.next_bill_sdate, nowdate())
|
||||
|
||||
|
||||
# Calculate next billing date day
|
||||
# --------------------------------
|
||||
def calc_next_day(self, next_year, next_month):
|
||||
bill_cycle_day = cstr(self.doc.billing_cycle_date).split('-')[2]
|
||||
if cint(next_month) == 2 and next_year%4==0 and (next_year%100!=0 or next_year%400==0) and cint(bill_cycle_day) > 28:
|
||||
bill_cycle_day = '28'
|
||||
elif cint(bill_cycle_day) == 31 and cint(next_month) in (4,6,9,11):
|
||||
bill_cycle_day = '30'
|
||||
return bill_cycle_day
|
||||
|
||||
|
||||
# Update acc credits and balance (making payment from gateway)
|
||||
# -------------------------------------------------------------
|
||||
def update_acc_bal(self,args):
|
||||
args = eval(args)
|
||||
self.doc.credit_balance = cint(self.doc.credit_balance) + cint(args.get('net_cr'))
|
||||
self.doc.total_users = cint(self.doc.total_users) + cint(args.get('total_users'))
|
||||
if cint(self.doc.is_trial_account) == 1:
|
||||
if not self.doc.account_start_date:
|
||||
self.doc.account_start_date = nowdate()
|
||||
self.doc.is_trial_account = 0
|
||||
self.doc.billing_cycle_date = nowdate()
|
||||
self.doc.last_deduction_date = nowdate()
|
||||
self.doc.save()
|
||||
|
||||
|
||||
# Check Credit Balance
|
||||
# ---------------------
|
||||
def check_credit_balance(self):
|
||||
if cint(self.doc.is_trial_account) == 0:
|
||||
if cint(self.doc.credit_balance) < 1:
|
||||
msgprint("You do not have enough credits to add new user. Please buy credits.")
|
||||
raise Exception
|
||||
else:
|
||||
self.doc.credit_balance = cint(self.doc.credit_balance) - 1
|
||||
msgprint("Your one credit is consumed. Balance Credits : %s" % (self.doc.credit_balance))
|
||||
self.doc.total_users = cint(self.doc.total_users) + 1
|
||||
self.doc.save()
|
||||
|
||||
|
||||
# Monthly Deduction
|
||||
# ------------------
|
||||
def monthly_deduction(self, cr_ded):
|
||||
self.doc.credit_balance = cint(self.doc.credit_balance) - cint(cr_ded)
|
||||
self.doc.last_deduction_date = nowdate()
|
||||
self.doc.save()
|
||||
@@ -0,0 +1,124 @@
|
||||
# DocType, WN ERP Client Control
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2010-08-08 17:09:30',
|
||||
'docstatus': 0,
|
||||
'modified': '2010-09-20 14:06:57',
|
||||
'modified_by': 'Administrator',
|
||||
'owner': 'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all DocType
|
||||
{
|
||||
'colour': 'White:FFF',
|
||||
'doctype': 'DocType',
|
||||
'issingle': 1,
|
||||
'istable': 0,
|
||||
'module': 'Utilities',
|
||||
'name': '__common__',
|
||||
'read_only': 1,
|
||||
'section_style': 'Simple',
|
||||
'server_code_error': ' ',
|
||||
'show_in_menu': 1,
|
||||
'version': 137
|
||||
},
|
||||
|
||||
# These values are common for all DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'name': '__common__',
|
||||
'parent': 'WN ERP Client Control',
|
||||
'parentfield': 'fields',
|
||||
'parenttype': 'DocType',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# These values are common for all DocPerm
|
||||
{
|
||||
'doctype': 'DocPerm',
|
||||
'name': '__common__',
|
||||
'parent': 'WN ERP Client Control',
|
||||
'parentfield': 'permissions',
|
||||
'parenttype': 'DocType',
|
||||
'read': 1,
|
||||
'role': 'System Manager'
|
||||
},
|
||||
|
||||
# DocType, WN ERP Client Control
|
||||
{
|
||||
'doctype': 'DocType',
|
||||
'name': 'WN ERP Client Control'
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'create': 1,
|
||||
'doctype': 'DocPerm',
|
||||
'idx': 1,
|
||||
'permlevel': 0,
|
||||
'write': 1
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'doctype': 'DocPerm',
|
||||
'idx': 2,
|
||||
'permlevel': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'account_start_date',
|
||||
'fieldtype': 'Date',
|
||||
'idx': 1,
|
||||
'label': 'Account Start Date'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'billing_cycle_date',
|
||||
'fieldtype': 'Date',
|
||||
'idx': 2,
|
||||
'label': 'Billing Cycle Date'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'total_users',
|
||||
'fieldtype': 'Int',
|
||||
'idx': 3,
|
||||
'label': 'Total Users'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'credit_balance',
|
||||
'fieldtype': 'Int',
|
||||
'idx': 4,
|
||||
'label': 'Credit Balance'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'is_trial_account',
|
||||
'fieldtype': 'Check',
|
||||
'idx': 5,
|
||||
'label': 'Is Trial Account'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'last_deduction_date',
|
||||
'fieldtype': 'Date',
|
||||
'idx': 6,
|
||||
'label': 'Last Credit Deduction Date'
|
||||
}
|
||||
]
|
||||
0
utilities/page/__init__.py
Normal file
0
utilities/page/__init__.py
Normal file
0
utilities/page/file_browser/__init__.py
Normal file
0
utilities/page/file_browser/__init__.py
Normal file
55
utilities/page/file_browser/file_browser.html
Normal file
55
utilities/page/file_browser/file_browser.html
Normal file
@@ -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>
|
||||
992
utilities/page/file_browser/file_browser.js
Normal file
992
utilities/page/file_browser/file_browser.js
Normal file
@@ -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(); }
|
||||
}
|
||||
121
utilities/page/file_browser/file_browser.txt
Normal file
121
utilities/page/file_browser/file_browser.txt
Normal file
@@ -0,0 +1,121 @@
|
||||
# Page, File Browser
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2010-10-12 15:19:31',
|
||||
'docstatus': 0,
|
||||
'modified': '2010-12-27 11:09:52',
|
||||
'modified_by': 'Administrator',
|
||||
'owner': 'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all Page
|
||||
{
|
||||
'doctype': 'Page',
|
||||
'module': 'Utilities',
|
||||
'name': '__common__',
|
||||
'page_name': 'File Browser',
|
||||
'show_in_menu': 1,
|
||||
'standard': 'Yes'
|
||||
},
|
||||
|
||||
# These values are common for all Page Role
|
||||
{
|
||||
'doctype': 'Page Role',
|
||||
'name': '__common__',
|
||||
'parent': 'File Browser',
|
||||
'parentfield': 'roles',
|
||||
'parenttype': 'Page'
|
||||
},
|
||||
|
||||
# Page, File Browser
|
||||
{
|
||||
'doctype': 'Page',
|
||||
'name': 'File Browser'
|
||||
},
|
||||
|
||||
# Page Role
|
||||
{
|
||||
'doctype': 'Page Role',
|
||||
'idx': 1,
|
||||
'role': 'Administrator'
|
||||
},
|
||||
|
||||
# Page Role
|
||||
{
|
||||
'doctype': 'Page Role',
|
||||
'idx': 2,
|
||||
'role': 'Sales User'
|
||||
},
|
||||
|
||||
# Page Role
|
||||
{
|
||||
'doctype': 'Page Role',
|
||||
'idx': 3,
|
||||
'role': 'Sales Manager'
|
||||
},
|
||||
|
||||
# Page Role
|
||||
{
|
||||
'doctype': 'Page Role',
|
||||
'idx': 4,
|
||||
'role': 'System Manager'
|
||||
},
|
||||
|
||||
# Page Role
|
||||
{
|
||||
'doctype': 'Page Role',
|
||||
'idx': 5,
|
||||
'role': 'Purchase User'
|
||||
},
|
||||
|
||||
# Page Role
|
||||
{
|
||||
'doctype': 'Page Role',
|
||||
'idx': 6,
|
||||
'role': 'Purchase Manager'
|
||||
},
|
||||
|
||||
# Page Role
|
||||
{
|
||||
'doctype': 'Page Role',
|
||||
'idx': 7,
|
||||
'role': 'Accounts User'
|
||||
},
|
||||
|
||||
# Page Role
|
||||
{
|
||||
'doctype': 'Page Role',
|
||||
'idx': 8,
|
||||
'role': 'Accounts Manager'
|
||||
},
|
||||
|
||||
# Page Role
|
||||
{
|
||||
'doctype': 'Page Role',
|
||||
'idx': 9,
|
||||
'role': 'Production User'
|
||||
},
|
||||
|
||||
# Page Role
|
||||
{
|
||||
'doctype': 'Page Role',
|
||||
'idx': 10,
|
||||
'role': 'Production Manager'
|
||||
},
|
||||
|
||||
# Page Role
|
||||
{
|
||||
'doctype': 'Page Role',
|
||||
'idx': 11,
|
||||
'role': 'Material User'
|
||||
},
|
||||
|
||||
# Page Role
|
||||
{
|
||||
'doctype': 'Page Role',
|
||||
'idx': 12,
|
||||
'role': 'Customer'
|
||||
}
|
||||
]
|
||||
0
utilities/page/messages/__init__.py
Normal file
0
utilities/page/messages/__init__.py
Normal file
2
utilities/page/messages/messages.html
Normal file
2
utilities/page/messages/messages.html
Normal file
@@ -0,0 +1,2 @@
|
||||
<div id="message_header" style="margin-bottom: 8px"></div>
|
||||
<div id="inbox_tabs"></div>
|
||||
929
utilities/page/messages/messages.js
Normal file
929
utilities/page/messages/messages.js
Normal file
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
1
utilities/page/messages/messages.txt
Normal file
1
utilities/page/messages/messages.txt
Normal file
@@ -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'}]
|
||||
2
utilities/page/messages/messages_static.html
Normal file
2
utilities/page/messages/messages_static.html
Normal file
@@ -0,0 +1,2 @@
|
||||
<div>
|
||||
</div>
|
||||
0
utilities/page/trash/__init__.py
Normal file
0
utilities/page/trash/__init__.py
Normal file
2
utilities/page/trash/trash.html
Normal file
2
utilities/page/trash/trash.html
Normal file
@@ -0,0 +1,2 @@
|
||||
<div id="trash_header"> </div>
|
||||
<div id="trash_div" style="margin: 0px;"> </div>
|
||||
128
utilities/page/trash/trash.js
Normal file
128
utilities/page/trash/trash.js
Normal file
@@ -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();})
|
||||
}
|
||||
72
utilities/page/trash/trash.txt
Normal file
72
utilities/page/trash/trash.txt
Normal file
@@ -0,0 +1,72 @@
|
||||
# Page, Trash
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2010-10-12 15:19:32',
|
||||
'docstatus': 0,
|
||||
'modified': '2010-12-30 11:44:36',
|
||||
'modified_by': 'Administrator',
|
||||
'owner': 'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all Page
|
||||
{
|
||||
'doctype': 'Page',
|
||||
'module': 'Utilities',
|
||||
'name': '__common__',
|
||||
'page_name': 'Trash',
|
||||
'show_in_menu': 0,
|
||||
'standard': 'Yes'
|
||||
},
|
||||
|
||||
# These values are common for all Page Role
|
||||
{
|
||||
'doctype': 'Page Role',
|
||||
'name': '__common__',
|
||||
'parent': 'Trash',
|
||||
'parentfield': 'roles',
|
||||
'parenttype': 'Page'
|
||||
},
|
||||
|
||||
# Page, Trash
|
||||
{
|
||||
'doctype': 'Page',
|
||||
'name': 'Trash'
|
||||
},
|
||||
|
||||
# Page Role
|
||||
{
|
||||
'doctype': 'Page Role',
|
||||
'idx': 1,
|
||||
'role': 'Administrator'
|
||||
},
|
||||
|
||||
# Page Role
|
||||
{
|
||||
'doctype': 'Page Role',
|
||||
'idx': 2,
|
||||
'role': 'Sales Master Manager'
|
||||
},
|
||||
|
||||
# Page Role
|
||||
{
|
||||
'doctype': 'Page Role',
|
||||
'idx': 3,
|
||||
'role': 'Material Master Manager'
|
||||
},
|
||||
|
||||
# Page Role
|
||||
{
|
||||
'doctype': 'Page Role',
|
||||
'idx': 4,
|
||||
'role': 'Purchase Master Manager'
|
||||
},
|
||||
|
||||
# Page Role
|
||||
{
|
||||
'doctype': 'Page Role',
|
||||
'idx': 5,
|
||||
'role': 'Accounts Manager'
|
||||
}
|
||||
]
|
||||
0
utilities/page/wip_monitor/__init__.py
Normal file
0
utilities/page/wip_monitor/__init__.py
Normal file
2
utilities/page/wip_monitor/wip_monitor.html
Normal file
2
utilities/page/wip_monitor/wip_monitor.html
Normal file
@@ -0,0 +1,2 @@
|
||||
<div id="wip_head"></div>
|
||||
<div id="wip_body" style="margin:16px"></div>
|
||||
88
utilities/page/wip_monitor/wip_monitor.js
Normal file
88
utilities/page/wip_monitor/wip_monitor.js
Normal file
@@ -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); }
|
||||
}
|
||||
28
utilities/page/wip_monitor/wip_monitor.txt
Normal file
28
utilities/page/wip_monitor/wip_monitor.txt
Normal file
@@ -0,0 +1,28 @@
|
||||
# Page, WIP Monitor
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2010-12-14 10:23:29',
|
||||
'docstatus': 0,
|
||||
'modified': '2011-01-04 11:12:39',
|
||||
'modified_by': 'Administrator',
|
||||
'owner': 'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all Page
|
||||
{
|
||||
'doctype': 'Page',
|
||||
'module': 'Utilities',
|
||||
'name': '__common__',
|
||||
'page_name': 'WIP Monitor',
|
||||
'show_in_menu': 0,
|
||||
'standard': 'Yes'
|
||||
},
|
||||
|
||||
# Page, WIP Monitor
|
||||
{
|
||||
'doctype': 'Page',
|
||||
'name': 'WIP Monitor'
|
||||
}
|
||||
]
|
||||
Reference in New Issue
Block a user