sms fix
This commit is contained in:
parent
df9f8a363e
commit
611157447f
@ -47,7 +47,6 @@ class DocType:
|
||||
if self.doc.send_to == 'All Sales Partner Contact':
|
||||
where_clause = self.doc.sales_partner and " and ifnull(is_sales_partner, 0) = 1 and sales_aprtner = '%s'" % self.doc.sales_partner or " and ifnull(is_sales_partner, 0) = 1"
|
||||
if self.doc.send_to in ['All Contact', 'All Customer Contact', 'All Supplier Contact', 'All Sales Partner Contact']:
|
||||
msgprint("select CONCAT(ifnull(first_name,''),'',ifnull(last_name,'')), mobile_no from `tabContact` where ifnull(mobile_no,'')!='' and docstatus != 2 %s" % where_clause)
|
||||
rec = 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 = sql("select lead_name, mobile_no from tabLead where ifnull(mobile_no,'')!='' and docstatus != 2 and status = 'Open'")
|
||||
|
@ -78,6 +78,11 @@
|
||||
title = "Sales campaigns"
|
||||
href="#!List/Campaign">Campaign</a>
|
||||
</div>
|
||||
<div class="section-item">
|
||||
<a class="section-link"
|
||||
title = "Send mass SMS to your conatacts, leads and employees"
|
||||
href="#!Form/SMS Center/SMS Center">SMS Center</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="section">
|
||||
@ -93,7 +98,7 @@
|
||||
title = "Analyze Sales and Purchase trends and slice them based on item, customer, groups etc"
|
||||
href="#!Report/Profile/Trend Analyzer">Trend Analyzer</a>
|
||||
</div>
|
||||
<!--><div class="section-item">
|
||||
<!--<div class="section-item">
|
||||
<a class="section-link"
|
||||
title = "sales trends"
|
||||
href="#!Sales Dashboard">Sales Dashboard</a>
|
||||
|
@ -69,14 +69,6 @@ class DocType:
|
||||
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"
|
||||
sender_name = webnotes.conn.get_value('Global Defaults', None, 'sms_sender_name') or 'ERPNXT'
|
||||
@ -117,8 +109,7 @@ class DocType:
|
||||
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
|
||||
# ==========================================================
|
||||
@ -135,30 +126,6 @@ class DocType:
|
||||
|
||||
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):
|
||||
@ -182,8 +149,6 @@ class DocType:
|
||||
api_url += '?'
|
||||
return server, api_url
|
||||
|
||||
|
||||
|
||||
|
||||
# Create SMS Log
|
||||
# =========================================================
|
||||
@ -195,20 +160,4 @@ class DocType:
|
||||
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")
|
||||
sl.save(new=1)
|
Loading…
Reference in New Issue
Block a user