Merge pull request #1374 from akhileshdarjee/sms-center
SMS center character count
This commit is contained in:
commit
7f80485070
@ -1,9 +1,8 @@
|
||||
// Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
|
||||
// License: GNU General Public License v3. See license.txt
|
||||
|
||||
|
||||
cur_frm.add_fetch("bank_account", "company", "company");
|
||||
cur_frm.cscript.onload = function(doc, cdt, cdn){
|
||||
cur_frm.set_intro('<i class="icon-question" /> ' +
|
||||
wn._("Update clearance date of Journal Entries marked as 'Bank Vouchers'"))
|
||||
}
|
||||
}
|
17
erpnext/selling/doctype/sms_center/sms_center.js
Normal file
17
erpnext/selling/doctype/sms_center/sms_center.js
Normal file
@ -0,0 +1,17 @@
|
||||
// Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
|
||||
// License: GNU General Public License v3. See license.txt
|
||||
|
||||
$.extend(cur_frm.cscript, {
|
||||
message: function () {
|
||||
var total_words = this.frm.doc.message.length;
|
||||
var total_msg = 1;
|
||||
|
||||
if (total_words > 160) {
|
||||
total_msg = cint(total_words / 160);
|
||||
total_msg = (total_words % 160 == 0 ? total_msg : total_msg + 1);
|
||||
}
|
||||
|
||||
this.frm.set_value("total_words", total_words);
|
||||
this.frm.set_value("total_messages", this.frm.doc.message ? total_msg : 0);
|
||||
}
|
||||
});
|
@ -8,7 +8,7 @@ from webnotes.utils import cstr
|
||||
from webnotes.model import db_exists
|
||||
from webnotes.model.bean import copy_doclist
|
||||
from webnotes.model.code import get_obj
|
||||
from webnotes import msgprint
|
||||
from webnotes import msgprint, _
|
||||
|
||||
class DocType:
|
||||
def __init__(self, doc, doclist=[]):
|
||||
@ -25,33 +25,47 @@ class DocType:
|
||||
where_clause = self.doc.sales_partner and " and ifnull(is_sales_partner, 0) = 1 and sales_partner = '%s'" % self.doc.sales_partner or " and ifnull(sales_partner, '') != ''"
|
||||
|
||||
if self.doc.send_to in ['All Contact', 'All Customer Contact', 'All Supplier Contact', 'All Sales Partner Contact']:
|
||||
rec = webnotes.conn.sql("select CONCAT(ifnull(first_name,''),'',ifnull(last_name,'')), mobile_no from `tabContact` where ifnull(mobile_no,'')!='' and docstatus != 2 %s" % where_clause)
|
||||
rec = webnotes.conn.sql("""select CONCAT(ifnull(first_name,''), '', ifnull(last_name,'')),
|
||||
mobile_no from `tabContact` where ifnull(mobile_no,'')!='' and
|
||||
docstatus != 2 %s""", where_clause)
|
||||
|
||||
elif self.doc.send_to == 'All Lead (Open)':
|
||||
rec = webnotes.conn.sql("select lead_name, mobile_no from tabLead where ifnull(mobile_no,'')!='' and docstatus != 2 and status = 'Open'")
|
||||
rec = webnotes.conn.sql("""select lead_name, mobile_no from `tabLead` where
|
||||
ifnull(mobile_no,'')!='' and docstatus != 2 and status='Open'""")
|
||||
|
||||
elif self.doc.send_to == 'All Employee (Active)':
|
||||
where_clause = self.doc.department and " and department = '%s'" % self.doc.department or ""
|
||||
where_clause += self.doc.branch and " and branch = '%s'" % self.doc.branch or ""
|
||||
rec = webnotes.conn.sql("select employee_name, cell_number from `tabEmployee` where status = 'Active' and docstatus < 2 and ifnull(cell_number,'')!='' %s" % where_clause)
|
||||
rec = webnotes.conn.sql("""select employee_name, cell_number from
|
||||
`tabEmployee` where status = 'Active' and docstatus < 2 and
|
||||
ifnull(cell_number,'')!='' %s""", where_clause)
|
||||
|
||||
elif self.doc.send_to == 'All Sales Person':
|
||||
rec = webnotes.conn.sql("select sales_person_name, mobile_no from `tabSales Person` where docstatus != 2 and ifnull(mobile_no,'')!=''")
|
||||
rec = webnotes.conn.sql("""select sales_person_name, mobile_no from
|
||||
`tabSales Person` where docstatus!=2 and ifnull(mobile_no,'')!=''""")
|
||||
rec_list = ''
|
||||
|
||||
for d in rec:
|
||||
rec_list += d[0] + ' - ' + d[1] + '\n'
|
||||
self.doc.receiver_list = rec_list
|
||||
|
||||
def get_receiver_nos(self):
|
||||
receiver_nos = []
|
||||
for d in self.doc.receiver_list.split('\n'):
|
||||
receiver_no = d
|
||||
if '-' in d:
|
||||
receiver_no = receiver_no.split('-')[1]
|
||||
if receiver_no.strip():
|
||||
receiver_nos.append(cstr(receiver_no).strip())
|
||||
if self.doc.receiver_list:
|
||||
for d in self.doc.receiver_list.split('\n'):
|
||||
receiver_no = d
|
||||
if '-' in d:
|
||||
receiver_no = receiver_no.split('-')[1]
|
||||
if receiver_no.strip():
|
||||
receiver_nos.append(cstr(receiver_no).strip())
|
||||
else:
|
||||
msgprint(_("Receiver List is empty. Please create Receiver List"))
|
||||
|
||||
return receiver_nos
|
||||
|
||||
def send_sms(self):
|
||||
if not self.doc.message:
|
||||
msgprint("Please enter message before sending")
|
||||
msgprint(_("Please enter message before sending"))
|
||||
else:
|
||||
receiver_list = self.get_receiver_nos()
|
||||
if receiver_list:
|
||||
|
@ -2,15 +2,13 @@
|
||||
{
|
||||
"creation": "2013-01-10 16:34:22",
|
||||
"docstatus": 0,
|
||||
"modified": "2013-07-05 14:55:36",
|
||||
"modified": "2014-01-30 15:29:04",
|
||||
"modified_by": "Administrator",
|
||||
"owner": "Administrator"
|
||||
},
|
||||
{
|
||||
"allow_attach": 0,
|
||||
"allow_copy": 1,
|
||||
"allow_email": 1,
|
||||
"allow_print": 1,
|
||||
"doctype": "DocType",
|
||||
"hide_heading": 0,
|
||||
"hide_toolbar": 0,
|
||||
@ -30,15 +28,19 @@
|
||||
"permlevel": 0
|
||||
},
|
||||
{
|
||||
"cancel": 0,
|
||||
"create": 1,
|
||||
"delete": 0,
|
||||
"doctype": "DocPerm",
|
||||
"export": 0,
|
||||
"import": 0,
|
||||
"name": "__common__",
|
||||
"parent": "SMS Center",
|
||||
"parentfield": "permissions",
|
||||
"parenttype": "DocType",
|
||||
"permlevel": 0,
|
||||
"read": 1,
|
||||
"report": 1,
|
||||
"report": 0,
|
||||
"role": "System Manager",
|
||||
"submit": 0,
|
||||
"write": 1
|
||||
@ -119,6 +121,20 @@
|
||||
"label": "Message",
|
||||
"reqd": 1
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "total_words",
|
||||
"fieldtype": "Int",
|
||||
"label": "Total Words",
|
||||
"read_only": 1
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "total_messages",
|
||||
"fieldtype": "Int",
|
||||
"label": "Total Message(s)",
|
||||
"read_only": 1
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "send_sms",
|
||||
@ -129,4 +145,4 @@
|
||||
{
|
||||
"doctype": "DocPerm"
|
||||
}
|
||||
]
|
||||
]
|
Loading…
x
Reference in New Issue
Block a user