Beispiel #1
0
def get_support_ticket(code,sender_no,message,_type='POST'):
	#return "hello"
	from webnotes.utils import get_first_day, get_last_day, add_to_date, nowdate, getdate
	today = nowdate()
        from webnotes.model.doc import Document
	import time
	#return sender_no[-11:]
	if code[1:-1] =="CRT":
		#return "hello"
		#return sender_no[1:-1]
		msg="Dear Customer,According to your request ticket is created"
	        d= Document('Support Ticket')
		d.opening_time=time.strftime("%H:%M:%S")
		d.opening_date=today
        	d.subject=message[1:-1]
        	d.raised_by=sender_no[1:-1]
		d.company='medsynaptic'
		d.status='Open'
        	d.save()
        	webnotes.conn.commit()
		#p=send_sms(message[1:-1],sender_no1[1:-1])
        	return d.name

	elif code[1:-1]=="CLS":
		#return "hii"
		#msg="Ticket Closed"
		#sender_no1=sender_no[-11:]
		z="select name from `tabSupport Ticket` where raised_by="+sender_no[1:-1]+" and status='Open'"
		x=webnotes.conn.sql(z)
		#return x 
		msg="Dear Customer,according to your request respective ticket is closed"
		if x:

			g="update `tabSupport Ticket` set status='Closed' where name='%s'"%(x[0][0])
			h=webnotes.conn.sql(g)
			#e=send_sms(message[1:-1],sender_no1[1:-1])
			return "Updated" 
			 

		else:
			pass

	else:
		pass
Beispiel #2
0
def get_customer_issue(installationname,sender_no,message,_type='POST'):
		#return installationname[1:-1]
		#sender_no1=sender_no[-11:]
		
		qr="select customer,employee_id from `tabInstallation Note` where name='"+installationname[1:-1]+"' "
        	res=webnotes.conn.sql(qr)
        	#return qr
		x="select customer_name from `tabCustomer` where customer_no='"+sender_no[1:-1]+"' "
		y=webnotes.conn.sql(x)
		#return x
		if y == None:
		
			z="select user_id from `tabEmployee` where cell_number="+sender_no[1:-1]+""	
			m=webnotes.conn.sql(z)
			#return m
		w="select status,user_id from `tabEmployee` where name='%s'"%(res[0][1]);
		t=webnotes.conn.sql(w)
		#return t
		from webnotes.utils import get_first_day, get_last_day, add_to_date, nowdate, getdate
		today = nowdate()
		qry="select name from `tabFiscal Year` where is_fiscal_year_closed='No'"
        	res1=webnotes.conn.sql(qry)
	
		q=" select territory from `tabCustomer` where name='%s'"%(res[0][0]);

		r=webnotes.conn.sql(q)	
	 	w=" select parent from `tabDefaultValue` where  defkey = '%s' and defvalue = '%s'"%('territory',r[0][0])
		a=webnotes.conn.sql(w)
		#return a
		from webnotes.model.doc import Document
		import time
	
    		#if res :
        	d = Document('Support Ticket')
		d.opening_time=time.strftime("%H:%M:%S")
		if y:
			d.raised_by=y[0][0]
		elif z:
			d.raised_by=z[0][0]
		else:
			d.raised_by=sender_no1[-11:]
        	d.subject=installationname[1:-1]
		d.customer_name=res[0][0]
		d.customer=res[0][0]
		d.territory=r[0][0]
		d.status='Open'
		#d.customer_group='Individual'
		d.opening_date=today
        	#d.fiscal_year=res1[0][0]
        	d.company='medsynaptic'
        	d.territory=r[0][0]
		#d.raised_by=res[0][1]
		if t[0][0] =='Active':
			#return t[0][1]
			d.assigned_to=t[0][1]
			d.assigned_to_higher_level=a[0][0]
		else:
			d.assigned_to=a[0][0]
			d.assigned_to_higher_level=a[0][0]
		
		#d.assigned_to_higher_level=a[0][0]
        	#return d.fiscal_year
        	d.save()
        	webnotes.conn.commit()
		#return sender_no[1:-1]
		p=send_sms(message[1:-1],sender_no[1:-1])

        	return d.name