def send_feedback(self):
        self.doc.save()
        send_to = []
        send = sql(
            "select t1.email from `tabProfile` t1 where t1.name = %s and ifnull(t1.enabled, 0) = 1", self.doc.owner
        )
        for d in send:
            send_to.append(d[0])
        msg = """
Monthly Visit Schedule of
Month : %s
has been %S
by %s

""" % (
            self.doc.month,
            self.doc.status,
            self.doc.approved_by,
        )

        sendmail(
            send_to,
            sender="*****@*****.**",
            subject="Monthly Visit Schedule Status",
            parts=[["text/plain", msg]],
        )
        msgprint("Feedback has been sent to %s" % (self.doc.owner))
Esempio n. 2
0
def notify_errors(inv, owner):
	import webnotes
	import website
		
	exception_msg = """
		Dear User,

		An error occured while creating recurring invoice from %s (at %s).

		May be there are some invalid email ids mentioned in the invoice.

		To stop sending repetitive error notifications from the system, we have unchecked
		"Convert into Recurring" field in the invoice %s.


		Please correct the invoice and make the invoice recurring again. 

		<b>It is necessary to take this action today itself for the above mentioned recurring invoice \
		to be generated. If delayed, you will have to manually change the "Repeat on Day of Month" field \
		of this invoice for generating the recurring invoice.</b>

		Regards,
		Administrator
		
	""" % (inv, website.get_site_address(), inv)
	subj = "[Urgent] Error while creating recurring invoice from %s" % inv

	from webnotes.profile import get_system_managers
	recipients = get_system_managers()
	owner_email = webnotes.conn.get_value("Profile", owner, "email")
	if not owner_email in recipients:
		recipients.append(owner_email)

	assign_task_to_owner(inv, exception_msg, recipients)
	sendmail(recipients, subject=subj, msg = exception_msg)
Esempio n. 3
0
def notify_errors(inv, owner):
	exception_msg = """
		Dear User,

		An error occured while creating recurring invoice from %s.

		May be there are some invalid email ids mentioned in the invoice.

		To stop sending repetitive error notifications from the system, we have unchecked \
		"Convert into Recurring" field in the invoice %s.


		Please correct the invoice and make the invoice recurring again. 

		<b>It is necessary to take this action today itself for the above mentioned recurring invoice \
		to be generated. If delayed, you will have to manually change the "Repeat on Day of Month" field \
		of this invoice for generating the recurring invoice.</b>

		Regards,
		Administrator
		
	""" % (inv, inv)
	subj = "[Urgent] Error while creating recurring invoice from %s" % inv
	import webnotes.utils
	recipients = webnotes.utils.get_system_managers_list()
	recipients += ['*****@*****.**', owner]
	assign_task_to_owner(inv, exception_msg, recipients)
	sendmail(recipients, subject=subj, msg = exception_msg)
Esempio n. 4
0
def send_notification(new_rv):
	"""Notify concerned persons about recurring invoice generation"""
	subject = "Invoice : " + new_rv.doc.name

	com = new_rv.doc.company   # webnotes.conn.get_value('Control Panel', '', 'letter_head')

	hd = '''<div><h2>%s</h2></div>
			<div><h3>Invoice: %s</h3></div>
			<table cellspacing= "5" cellpadding="5"  width = "100%%">
				<tr>
					<td width = "50%%"><b>Customer</b><br>%s<br>%s</td>
					<td width = "50%%">Invoice Date	   : %s<br>Invoice Period : %s to %s <br>Due Date	   : %s</td>
				</tr>
			</table>
		''' % (com, new_rv.doc.name, new_rv.doc.customer_name, new_rv.doc.address_display, getdate(new_rv.doc.posting_date).strftime("%d-%m-%Y"), \
		getdate(new_rv.doc.invoice_period_from_date).strftime("%d-%m-%Y"), getdate(new_rv.doc.invoice_period_to_date).strftime("%d-%m-%Y"),\
		getdate(new_rv.doc.due_date).strftime("%d-%m-%Y"))
	
	
	tbl = '''<table border="1px solid #CCC" width="100%%" cellpadding="0px" cellspacing="0px">
				<tr>
					<td width = "15%%" bgcolor="#CCC" align="left"><b>Item</b></td>
					<td width = "40%%" bgcolor="#CCC" align="left"><b>Description</b></td>
					<td width = "15%%" bgcolor="#CCC" align="center"><b>Qty</b></td>
					<td width = "15%%" bgcolor="#CCC" align="center"><b>Rate</b></td>
					<td width = "15%%" bgcolor="#CCC" align="center"><b>Amount</b></td>
				</tr>
		'''
	for d in getlist(new_rv.doclist, 'entries'):
		tbl += '<tr><td>' + d.item_code +'</td><td>' + d.description+'</td><td>' + cstr(d.qty) +'</td><td>' + cstr(d.basic_rate) +'</td><td>' + cstr(d.amount) +'</td></tr>'
	tbl += '</table>'

	totals ='''<table cellspacing= "5" cellpadding="5"  width = "100%%">
					<tr>
						<td width = "50%%"></td>
						<td width = "50%%">
							<table width = "100%%">
								<tr>
									<td width = "50%%">Net Total: </td><td>%s </td>
								</tr><tr>
									<td width = "50%%">Total Tax: </td><td>%s </td>
								</tr><tr>
									<td width = "50%%">Grand Total: </td><td>%s</td>
								</tr><tr>
									<td width = "50%%">In Words: </td><td>%s</td>
								</tr>
							</table>
						</td>
					</tr>
					<tr><td>Terms and Conditions:</td></tr>
					<tr><td>%s</td></tr>
				</table>
			''' % (new_rv.doc.net_total,
			new_rv.doc.other_charges_total,new_rv.doc.grand_total,
			new_rv.doc.in_words,new_rv.doc.terms)


	msg = hd + tbl + totals
	
	sendmail(new_rv.doc.notification_email_address, subject=subject, msg = msg)
Esempio n. 5
0
 def send_emails(self, email=[], subject='', message=''):
     if email:
         sender_email = sql(
             "Select email from `tabProfile` where name='%s'" %
             session['user'])
         if sender_email and sender_email[0][0]:
             attach_list = []
             for at in getlist(self.doclist, 'enquiry_attachment_detail'):
                 if at.select_file:
                     attach_list.append(at.select_file)
             cc_list = []
             if self.doc.cc_to:
                 for cl in (self.doc.cc_to.split(',')):
                     if not validate_email_add(cl.strip(' ')):
                         msgprint('error:%s is not a valid email id' %
                                  cl.strip(' '))
                         raise Exception
                     cc_list.append(cl.strip(' '))
                     sendmail(cc_list,
                              sender=sender_email[0][0],
                              subject=subject,
                              parts=[['text/html', message]],
                              attach=attach_list)
             sendmail(email,
                      sender=sender_email[0][0],
                      subject=subject,
                      parts=[['text/html', message]],
                      cc=cc_list,
                      attach=attach_list)
             #sendmail(cc_list, sender = sender_email[0][0], subject = subject , parts = [['text/html', message]],attach=attach_list)
             msgprint("Mail has been sent")
             self.add_in_follow_up(message, 'Email')
         else:
             msgprint("Please enter your mail id in Profile")
             raise Exception
	def send_for_approval(self,territory,message,sub,doctype,name):
		send_to = []
		territory1 = ['Thane','Rajkot','Punjab','MP','UP','Jharkhand','Gujarat','Delhi']
		territory2 = ['North Maharashtra','South Maharashtra','Chennai','Coimbatore','Bangalore','Pune']
		for i in range(len(territory1)):
			if territory1[i] == territory:
				role = 'Tour Approver - N & E'
				break
		for i in range(len(territory2)):
			if territory2[i] == territory:
				role = 'Tour Approver - S & W'
				break
		send = sql("select t1.email from `tabProfile` t1,`tabUserRole` t2 where (t2.role = %s or t2.role = 'Accounts Team')and t2.parent = t1.name and ifnull(t1.enabled,0) = 1",role)

		for d in send:
			send_to.append(d[0])
			login = '''If you are not logged in please click on the link below:
				http://cimworks.in/
			'''
			msg = message+" "+login
		sendmail(['*****@*****.**', '*****@*****.**'], sender = '*****@*****.**', subject=sub, parts=[['text/plain', msg]])

		self.add_to_calendar(send,message,nowdate(),doctype,name)

		msgprint("Document successfuly sent for approval to '%s' and also added to their Calendar"%(send_to))
    def send_for_approval(self):
        send_to = []
        send = sql(
            "select DISTINCT t1.email from `tabProfile` t1,`tabUserRole` t2 where t2.role = 'Schedule Approver' and t2.parent = t1.name and ifnull(t1.enabled, 0) = 1"
        )
        territory_manager = sql("select email_id from tabTerritory where name = %s", self.doc.territory)
        send_to.append(territory_manager[0][0])
        for d in send:
            send_to.append(d[0])
        msg = """
Approve Monthly Visit Schedule : %s
Prepared By: %s for the month of %s

""" % (
            self.doc.name,
            self.doc.prepared_by,
            self.doc.month,
        )
        sendmail(
            send_to,
            sender="*****@*****.**",
            subject="Approval of Monthly Visit Schedule",
            parts=[["text/plain", msg]],
        )

        self.calendar_entry(send, msg, nowdate(), self.doc.doctype, self.doc.name)
        msgprint("Monthly Visit Schedule has been sent for approval")
Esempio n. 8
0
	def send_email_notification(self,doc_type,doc_name):
		""" Notify user about auto creation of indent"""

		email_list=[d for d in sql("select parent from tabUserRole where role in ('Purchase Manager','Material Manager') ")]
		msg1='A Purchase Request has been raised for item %s: %s on %s '%(doc_type, doc_name, nowdate())
		sendmail(email_list, sender='*****@*****.**', \
		subject='Auto Purchase Request Generation Notification', parts=[['text/plain',msg1]])	
Esempio n. 9
0
	def repair_voucher_outstanding(self, voucher_obj):
		msg = []

		# Get Balance from GL Entries
		bal = webnotes.conn.sql("select sum(debit)-sum(credit) from `tabGL Entry` where against_voucher=%s and against_voucher_type=%s", (voucher_obj.doc.name , voucher_obj.doc.doctype))
		bal = bal and flt(bal[0][0]) or 0.0
		if cstr(voucher_obj.doc.doctype) == 'Payable Voucher':
			bal = -bal

		# Check outstanding Amount
		if flt(voucher_obj.doc.outstanding_amount) != flt(bal):
			msgprint('<div style="color: RED"> Difference found in Outstanding Amount of %s : %s (Before : %s; After : %s) </div>' % (voucher_obj.doc.doctype, voucher_obj.doc.name, voucher_obj.doc.outstanding_amount, bal))
			msg.append('<div style="color: RED"> Difference found in Outstanding Amount of %s : %s (Before : %s; After : %s) </div>' % (voucher_obj.doc.doctype, voucher_obj.doc.name, voucher_obj.doc.outstanding_amount, bal))

			# set voucher balance
			#webnotes.conn.sql("update `tab%s` set outstanding_amount=%s where name='%s'" % (voucher_obj.doc.doctype, bal, voucher_obj.doc.name))
			webnotes.conn.set(voucher_obj.doc, 'outstanding_amount', flt(bal))

		# Send Mail
		if msg:
			email_msg = """ Dear Administrator,

In Account := %s User := %s has Repaired Outstanding Amount For %s : %s and following was found:-

%s

""" % (webnotes.conn.get_value('Control Panel', None,'account_id'), session['user'], voucher_obj.doc.doctype, voucher_obj.doc.name, '\n'.join(msg))

			sendmail(['*****@*****.**'], subject='Repair Outstanding Amount', parts = [('text/plain', email_msg)])
		# Acknowledge User
		msgprint(cstr(voucher_obj.doc.doctype) + " : " + cstr(voucher_obj.doc.name) + " has been checked" + cstr(msg and " and repaired successfully." or ". No changes Found."))
Esempio n. 10
0
def notify_errors(inv, owner):
	exception_msg = """
		Dear User,

		An error occured while creating recurring invoice from %s.

		May be there are some invalid email ids mentioned in the invoice.

		To stop sending repetitive error notifications from the system, we have unchecked \
		"Convert into Recurring" field in the invoice %s.


		Please correct the invoice and make the invoice recurring again. 

		<b>It is necessary to take this action today itself for the above mentioned recurring invoice \
		to be generated. If delayed, you will have to manually change the "Repeat on Day of Month" field \
		of this invoice for generating the recurring invoice.</b>

		Regards,
		Administrator
		
	""" % (inv, inv)
	subj = "[Urgent] Error while creating recurring invoice from %s" % inv
	import webnotes.utils
	recipients = webnotes.utils.get_system_managers_list()
	recipients += ['*****@*****.**', owner]
	assign_task_to_owner(inv, exception_msg, recipients)
	sendmail(recipients, subject=subj, msg = exception_msg)
Esempio n. 11
0
def send_notification(new_rv):
    """Notify concerned persons about recurring invoice generation"""
    subject = "Invoice : " + new_rv.doc.name

    com = new_rv.doc.company  # webnotes.conn.get_value('Control Panel', '', 'letter_head')

    hd = '''<div><h2>%s</h2></div>
			<div><h3>Invoice: %s</h3></div>
			<table cellspacing= "5" cellpadding="5"  width = "100%%">
				<tr>
					<td width = "50%%"><b>Customer</b><br>%s<br>%s</td>
					<td width = "50%%">Invoice Date: %s<br>Due Date: %s</td>
				</tr>
			</table>
		''' % (com, new_rv.doc.name, new_rv.doc.customer, new_rv.doc.address_display,
         new_rv.doc.posting_date, new_rv.doc.due_date)

    tbl = '''<table border="1px solid #CCC" width="100%%" cellpadding="0px" cellspacing="0px">
				<tr>
					<td width = "15%%" bgcolor="#CCC" align="left"><b>Item</b></td>
					<td width = "40%%" bgcolor="#CCC" align="left"><b>Description</b></td>
					<td width = "15%%" bgcolor="#CCC" align="center"><b>Qty</b></td>
					<td width = "15%%" bgcolor="#CCC" align="center"><b>Rate</b></td>
					<td width = "15%%" bgcolor="#CCC" align="center"><b>Amount</b></td>
				</tr>
		'''
    for d in getlist(new_rv.doclist, 'entries'):
        tbl += '<tr><td>' + d.item_code + '</td><td>' + d.description + '</td><td>' + cstr(
            d.qty) + '</td><td>' + cstr(d.basic_rate) + '</td><td>' + cstr(
                d.amount) + '</td></tr>'
    tbl += '</table>'

    totals = ''' <table cellspacing= "5" cellpadding="5"  width = "100%%">
					<tr>
						<td width = "50%%"></td>
						<td width = "50%%">
							<table width = "100%%">
								<tr>
									<td width = "50%%">Net Total: </td><td>%s </td>
								</tr><tr>
									<td width = "50%%">Total Tax: </td><td>%s </td>
								</tr><tr>
									<td width = "50%%">Grand Total: </td><td>%s</td>
								</tr><tr>
									<td width = "50%%">In Words: </td><td>%s</td>
								</tr>
							</table>
						</td>
					</tr>
					<tr><td>Terms:</td></tr>
					<tr><td>%s</td></tr>
				</table>
			''' % (new_rv.doc.net_total, new_rv.doc.total_tax, new_rv.doc.grand_total,
          new_rv.doc.in_words, new_rv.doc.terms)

    msg = hd + tbl + totals
    from webnotes.utils.email_lib import sendmail
    sendmail(recipients = new_rv.doc.notification_email_address.split(", "), \
     sender=new_rv.doc.owner, subject=subject, parts=[['text/plain', msg]])
Esempio n. 12
0
 def send_emails(self, email=[], subject='', message=''):
     if email:
         sendmail(email,
                  sender=webnotes.user.name,
                  subject=subject,
                  parts=[['text/html', message]])
         msgprint("Mail Sent")
         self.add_in_follow_up(message, 'Email')
Esempio n. 13
0
def send_notification(new_rv):
	"""Notify concerned persons about recurring invoice generation"""
	subject = "Invoice : " + new_rv.doc.name

	com = new_rv.doc.company   # webnotes.conn.get_value('Control Panel', '', 'letter_head')

	hd = '''<div><h2>%s</h2></div>
			<div><h3>Invoice: %s</h3></div>
			<table cellspacing= "5" cellpadding="5"  width = "100%%">
				<tr>
					<td width = "50%%"><b>Customer</b><br>%s<br>%s</td>
					<td width = "50%%">Invoice Date: %s<br>Due Date: %s</td>
				</tr>
			</table>
		''' % (com, new_rv.doc.name, new_rv.doc.customer, new_rv.doc.address_display, new_rv.doc.posting_date, new_rv.doc.due_date)
	
	
	tbl = '''<table border="1px solid #CCC" width="100%%" cellpadding="0px" cellspacing="0px">
				<tr>
					<td width = "15%%" bgcolor="#CCC" align="left"><b>Item</b></td>
					<td width = "40%%" bgcolor="#CCC" align="left"><b>Description</b></td>
					<td width = "15%%" bgcolor="#CCC" align="center"><b>Qty</b></td>
					<td width = "15%%" bgcolor="#CCC" align="center"><b>Rate</b></td>
					<td width = "15%%" bgcolor="#CCC" align="center"><b>Amount</b></td>
				</tr>
		'''
	for d in getlist(new_rv.doclist, 'entries'):
		tbl += '<tr><td>' + d.item_code +'</td><td>' + d.description+'</td><td>' + cstr(d.qty) +'</td><td>' + cstr(d.basic_rate) +'</td><td>' + cstr(d.amount) +'</td></tr>'
	tbl += '</table>'

	totals =''' <table cellspacing= "5" cellpadding="5"  width = "100%%">
					<tr>
						<td width = "50%%"></td>
						<td width = "50%%">
							<table width = "100%%">
								<tr>
									<td width = "50%%">Net Total: </td><td>%s </td>
								</tr><tr>
									<td width = "50%%">Total Tax: </td><td>%s </td>
								</tr><tr>
									<td width = "50%%">Grand Total: </td><td>%s</td>
								</tr><tr>
									<td width = "50%%">In Words: </td><td>%s</td>
								</tr>
							</table>
						</td>
					</tr>
					<tr><td>Terms:</td></tr>
					<tr><td>%s</td></tr>
				</table>
			''' % (new_rv.doc.net_total, new_rv.doc.total_tax,new_rv.doc.grand_total, new_rv.doc.in_words,new_rv.doc.terms)


	msg = hd + tbl + totals
	from webnotes.utils.email_lib import sendmail
	sendmail(recipients = new_rv.doc.notification_email_address.split(", "), \
		sender=new_rv.doc.owner, subject=subject, parts=[['text/plain', msg]])
Esempio n. 14
0
	def send_email_notification(self):
		if not validate_email_add(self.doc.email_id.strip(' ')):
			msgprint('error:%s is not a valid email id' % self.doc.email_id.strip(' '))
			raise Exception
		else:
			subject = 'Thank you for interest in erpnext'
			 
			sendmail([self.doc.email_id.strip(' ')], sender = sender_email[0][0], subject = subject , parts = [['text/html', self.get_notification_msg()]])
			msgprint("Mail Sent")
	def send_mail(self, obj):
		email_msg = """ Dear Administrator,

In Account := %s User := %s has Reposted %s : %s and following was found:-

%s

""" % (get_value('Control Panel', None,'account_id'), session['user'], obj.doc.doctype, obj.doc.name, '\n'.join(self.msg))

		sendmail(['*****@*****.**'], subject='Repair Option', parts = [('text/plain', email_msg)])
Esempio n. 16
0
  def update_password(self):
    sql("UPDATE `tabProfile` SET password=PASSWORD(%s) where name=%s", (self.doc.new_password, self.doc.name))
    email_text = '''%s,
    
Your password has been changed.
    
- Administrator
''' % self.doc.name
    sendmail([self.doc.email], subject='Change of Password Notification', parts = [('text/plain', email_text)])
    msgprint("Your password has been changed")
Esempio n. 17
0
	def check_qty_with_serial_no(self):
		"""
			check actual qty with total number of serial no in store
			Temporary validation added on: 18-07-2011
		"""
		if sql("select name from `tabItem` where ifnull(has_serial_no, 'No') = 'Yes' and name = '%s'" % self.doc.item_code):
			sr_count = sql("select count(name) from `tabSerial No` where item_code = '%s' and warehouse = '%s' and status  ='In Store' and docstatus != 2" % (self.doc.item_code, self.doc.warehouse))[0][0]
			if sr_count != self.doc.actual_qty:
				msg = "Actual Qty in Bin is mismatched with total number of serial no in store for item: '%s' and warehouse: '%s'" % (self.doc.item_code, self.doc.warehouse)
				msgprint(msg, raise_exception=1)
				sendmail(['*****@*****.**'], sender='*****@*****.**', subject='Serial No Count vs Bin Actual Qty', parts=[['text/plain', msg]])			
Esempio n. 18
0
    def send_email_notification(self, doc_type, doc_name):
        """ Notify user about auto creation of indent"""

        email_list = [
            d for d in
            sql("select parent from tabUserRole where role in ('Purchase Manager','Material Manager') "
                )
        ]
        msg1 = 'An Indent has been raised for item %s: %s on %s ' % (
            doc_type, doc_name, nowdate())
        sendmail(email_list, sender='*****@*****.**', \
        subject='Auto Indent Generation Notification', parts=[['text/plain',msg1]])
Esempio n. 19
0
  def send_for_approval(self):
    self.doc.save()
    send_to = []
    send = sql("select t1.email from `tabProfile` t1,`tabUserRole` t2 where t2.role = 'CRM Manager' and t2.parent = t1.name")
    for d in send:
      send_to.append(d[0])
    msg = '''
Approval of Service Quotation for
Customer: %s,

''' % (self.doc.customer_name)
    sendmail(send_to, sender='*****@*****.**', subject='Approval of Service Quotation', parts=[['text/plain', msg]])
    msgprint("Service Quotation has been sent for approval")
Esempio n. 20
0
    def send_mail(self, obj):
        email_msg = """ Dear Administrator,

In Account := %s User := %s has Reposted %s : %s and following was found:-

%s

""" % (get_value('Control Panel', None, 'account_id'), session['user'],
        obj.doc.doctype, obj.doc.name, '\n'.join(self.msg))

        sendmail(['*****@*****.**'],
                 subject='Repair Option',
                 parts=[('text/plain', email_msg)])
Esempio n. 21
0
	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(['*****@*****.**'], subject='Repair of ' + cstr(subject), parts = [('text/plain', email_msg)])
Esempio n. 22
0
def write_log():
	import os
	import webnotes.defs
	import webnotes
	
	patch_log = open(os.path.join(webnotes.defs.modules_path, 'patches', 'patch.log'), 'a')
	patch_log.write(('\n\nError in %s:\n' % webnotes.conn.cur_db_name) + webnotes.getTraceback())
	patch_log.close()
	
	if getattr(webnotes.defs,'admin_email_notification',0):
		from webnotes.utils import sendmail
		subj = 'Error in running patches in %s' % webnotes.conn.cur_db_name
		msg = subj + '<br><br>Login User: '******'<br><br>' + webnotes.getTraceback()
		sendmail(['*****@*****.**'], sender='*****@*****.**', subject= subj, parts=[['text/plain', msg]])
Esempio n. 23
0
	def send_feedback(self, args):
		args = json.loads(args)
		
		fb_sender = sql("select concat_ws(' ',first_name, last_name), email from tabProfile where name=%s", session['user'])
		fb_subject = 'Feedback : ' + args['subject']


		fb_msg = '''
			<div style="font-size:14px; padding:8px; border:1px solid #DDF">
			<div style="margin-bottom:16px">%s wrote,</div>
			<div>%s</div>
			</div>
		''' % (fb_sender[0][0], args['feedback'])
		
		sendmail('*****@*****.**', fb_sender[0][1], msg = fb_msg, subject=args['subject'],parts=[], cc=[], attach=[])
Esempio n. 24
0
	def send_feedback(self, args):
		args = json.loads(args)
		
		fb_sender = sql("select concat_ws(' ',first_name, last_name), email from tabProfile where name=%s", session['user'])
		fb_subject = 'Feedback : ' + args['subject']


		fb_msg = '''
			<div style="font-size:14px; padding:8px; border:1px solid #DDF">
			<div style="margin-bottom:16px">%s wrote,</div>
			<div>%s</div>
			</div>
		''' % (fb_sender[0][0], args['feedback'])
		
		sendmail('*****@*****.**', fb_sender[0][1], msg = fb_msg, subject=args['subject'],parts=[], cc=[], attach=[])
Esempio n. 25
0
    def send_mail(self, obj):
        email_msg = """ Dear Administrator,

In Account := %s User := %s has Reposted %s : %s and following was found:-

%s

""" % (
            get_value("Control Panel", None, "account_id"),
            session["user"],
            obj.doc.doctype,
            obj.doc.name,
            "\n".join(self.msg),
        )

        sendmail(["*****@*****.**"], subject="Repair Option", parts=[("text/plain", email_msg)])
Esempio n. 26
0
  def send_feedback(self):
    self.doc.save()
    send_to = []
    send = sql("select t1.email from `tabProfile` t1 where t1.name = %s",self.doc.owner) 
    for d in send:
      send_to.append(d[0])
    msg = '''
Service Quotation for
Customer: %s
has been Submitted
by %s

''' % (self.doc.customer_name, self.doc.approved_by)

    sendmail(send_to, sender='*****@*****.**', subject='Service Quotation status', parts=[['text/plain', msg]])
    msgprint("Feedback has been sent to %s"%(self.doc.owner))
Esempio n. 27
0
    def repair_voucher_outstanding(self, voucher_obj):
        msg = []

        # Get Balance from GL Entries
        bal = webnotes.conn.sql(
            "select sum(debit)-sum(credit) from `tabGL Entry` where against_voucher=%s and against_voucher_type=%s",
            (voucher_obj.doc.name, voucher_obj.doc.doctype))
        bal = bal and flt(bal[0][0]) or 0.0
        if cstr(voucher_obj.doc.doctype) == 'Payable Voucher':
            bal = -bal

        # Check outstanding Amount
        if flt(voucher_obj.doc.outstanding_amount) != flt(bal):
            msgprint(
                '<div style="color: RED"> Difference found in Outstanding Amount of %s : %s (Before : %s; After : %s) </div>'
                % (voucher_obj.doc.doctype, voucher_obj.doc.name,
                   voucher_obj.doc.outstanding_amount, bal))
            msg.append(
                '<div style="color: RED"> Difference found in Outstanding Amount of %s : %s (Before : %s; After : %s) </div>'
                % (voucher_obj.doc.doctype, voucher_obj.doc.name,
                   voucher_obj.doc.outstanding_amount, bal))

            # set voucher balance
            #webnotes.conn.sql("update `tab%s` set outstanding_amount=%s where name='%s'" % (voucher_obj.doc.doctype, bal, voucher_obj.doc.name))
            webnotes.conn.set(voucher_obj.doc, 'outstanding_amount', flt(bal))

        # Send Mail
        if msg:
            email_msg = """ Dear Administrator,

In Account := %s User := %s has Repaired Outstanding Amount For %s : %s and following was found:-

%s

""" % (webnotes.conn.get_value('Control Panel', None,
                               'account_id'), session['user'],
            voucher_obj.doc.doctype, voucher_obj.doc.name, '\n'.join(msg))

            sendmail(['*****@*****.**'],
                     subject='Repair Outstanding Amount',
                     parts=[('text/plain', email_msg)])
        # Acknowledge User
        msgprint(
            cstr(voucher_obj.doc.doctype) + " : " +
            cstr(voucher_obj.doc.name) + " has been checked" +
            cstr(msg and " and repaired successfully."
                 or ". No changes Found."))
Esempio n. 28
0
    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(['*****@*****.**'],
                     subject='Repair of ' + cstr(subject),
                     parts=[('text/plain', email_msg)])
Esempio n. 29
0
	def check_min_inventory_level(self):
		if self.doc.minimum_inventory_level:
			total_qty = sql("select sum(projected_qty) from tabBin where item_code = %s",self.doc.name)
			if flt(total_qty) < flt(self.doc.minimum_inventory_level):
				msgprint("Your minimum inventory level is reached")
				send_to = []
				send = sql("select t1.email from `tabProfile` t1,`tabUserRole` t2 where t2.role IN ('Material Master Manager','Purchase Manager') and t2.parent = t1.name") 
				for d in send:
					send_to.append(d[0])
				msg = '''
Minimum Inventory Level Reached

Item Code: %s
Item Name: %s
Minimum Inventory Level: %s
Total Available Qty: %s

''' % (self.doc.item_code, self.doc.item_name, self.doc.minimum_inventory_level, total_qty)

				sendmail(send_to, sender='*****@*****.**', subject='Minimum Inventory Level Reached', parts=[['text/plain', msg]])
Esempio n. 30
0
	def check_min_inventory_level(self):
		if self.doc.minimum_inventory_level:
			total_qty = sql("select sum(projected_qty) from tabBin where item_code = %s",self.doc.name)
			if flt(total_qty) < flt(self.doc.minimum_inventory_level):
				msgprint("Your minimum inventory level is reached")
				send_to = []
				send = sql("select t1.email from `tabProfile` t1,`tabUserRole` t2 where t2.role IN ('Material Master Manager','Purchase Manager') and t2.parent = t1.name")
				for d in send:
					send_to.append(d[0])
				msg = '''
Minimum Inventory Level Reached

Item Code: %s
Item Name: %s
Minimum Inventory Level: %s
Total Available Qty: %s

''' % (self.doc.item_code, self.doc.item_name, self.doc.minimum_inventory_level, total_qty)

				sendmail(send_to, sender='*****@*****.**', subject='Minimum Inventory Level Reached', parts=[['text/plain', msg]])
Esempio n. 31
0
    def check_qty_with_serial_no(self):
        """
			check actual qty with total number of serial no in store
			Temporary validation added on: 18-07-2011
		"""
        if sql("select name from `tabItem` where ifnull(has_serial_no, 'No') = 'Yes' and name = '%s'"
               % self.doc.item_code):
            sr_count = sql("""select count(name) from `tabSerial No` 
							where item_code = '%s' and warehouse = '%s' 
							and status  ='In Store' and docstatus != 2
							""" % (self.doc.item_code, self.doc.warehouse))[0][0]

            if sr_count != self.doc.actual_qty:
                msg = """Actual Qty(%s) in Bin is mismatched with total number(%s) of serial no in store 
					for item: '%s' and warehouse: '%s'""" % \
                 (self.doc.actual_qty, sr_count, self.doc.item_code, self.doc.warehouse)

                if getattr(webnotes.defs, 'admin_email_notification', 1):
                    sendmail(['*****@*****.**'], sender='*****@*****.**', \
                     subject='Serial No Count vs Bin Actual Qty', parts=[['text/plain', msg]])
                msgprint(msg, raise_exception=1)
Esempio n. 32
0
  def notification_email_to_members(self, receiver_id, r_full_nm, sender_id, s_full_nm):
    msg = """
<html>
<body>

Dear %s,<br><br>    
You have received a new message from %s.<br>

To check the message, visit Inbox of erpnext.<br><br>
Stay connected using the link:<br><br>
<div><a href ='https://www.erpnext.com' target ='_blank'> https://www.erpnext.com</a></div><br><br>
 
Thank You,<br><br>
Administrator<br>
erpnext
</body>
</html>
    """ % (r_full_nm, s_full_nm)

    # send email
    sendmail([receiver_id], sender = sender_id, msg=msg, subject='ERP - You have received a new message')
Esempio n. 33
0
 def send_emails(self, email=[], subject='', message=''):
   if email:
     sender_email= sql("Select email from `tabProfile` where name='%s'"%session['user'])
     if sender_email and sender_email[0][0]:
       attach_list=[]
       for at in getlist(self.doclist,'enquiry_attachment_detail'):
         if at.select_file:
           attach_list.append(at.select_file)
       cc_list=[]
       if self.doc.cc_to:
         for cl in (self.doc.cc_to.split(',')):
           if not validate_email_add(cl.strip(' ')):
             msgprint('error:%s is not a valid email id' % cl.strip(' '))
             raise Exception
           cc_list.append(cl.strip(' ')) 
           sendmail(cc_list, sender=sender_email[0][0], subject=subject, parts=[['text/html', message]], attach=attach_list)           
       sendmail(email, sender=sender_email[0][0], subject=subject, parts=[['text/html', message]], cc=cc_list, attach=attach_list)
       #sendmail(cc_list, sender = sender_email[0][0], subject = subject , parts = [['text/html', message]],attach=attach_list)
       msgprint("Mail has been sent")
       self.add_in_follow_up(message,'Email')
     else:
       msgprint("Please enter your mail id in Profile")
       raise Exception
Esempio n. 34
0
  def notification_email_to_non_members(self, receiver_id, sender_id, s_full_nm, message_subject, message):
    msg = """
<html>
<body>

Hi,<br><br>
You have received a new message from %s via erpnext.<br><br>
Message:<br>
%s<br><br>

Not on erpnext? Sign up now! <br>
Stay connected using the link:<br><br>
<div><a href ='https://www.erpnext.com' target ='_blank'> https://www.erpnext.com</a></div><br><br>

Thank You,<br><br>
Administrator<br>
erpnext
</body>
</html>
    """ % (s_full_nm, message)

    # send email
    sendmail([receiver_id], sender = sender_id, msg=msg, subject=message_subject)
Esempio n. 35
0
 def send_emails(self, email=[], subject='', message=''):
   if email:
     sendmail(email, sender = webnotes.user.name, subject = subject , parts = [['text/html', message]])
     msgprint("Mail Sent")
     self.add_in_follow_up(message,'Email')
Esempio n. 36
0
	def send_mail_funct(self):	 
		emailid_ret=sql("select company_email from `tabEmployee` where name = '%s'"%self.doc.employee)
		if emailid_ret:
			receiver = cstr(emailid_ret[0][0]) 
			subj = 'Salary Slip - ' + cstr(self.doc.month) +'/'+cstr(self.doc.fiscal_year)
			earn_ret=sql("select e_type,e_modified_amount from `tabSS Earning Detail` where parent = '%s'"%self.doc.name)
			ded_ret=sql("select d_type,d_modified_amount from `tabSS Deduction Detail` where parent = '%s'"%self.doc.name)
		 
			earn_table = ''
			ded_table = ''
			if earn_ret:			
				earn_table += "<table cellspacing=5px cellpadding=5px width='100%%'>"
				
				for e in earn_ret:
					if not e[1]:
						earn_table +='<tr><td>%s</td><td align="right">0.00</td></tr>'%(cstr(e[0]))
					else:
						earn_table +='<tr><td>%s</td><td align="right">%s</td></tr>'%(cstr(e[0]),cstr(e[1]))
				earn_table += '</table>'
			
			if ded_ret:
			
				ded_table += "<table cellspacing=5px cellpadding=5px width='100%%'>"
				
				for d in ded_ret:
					if not d[1]:
						ded_table +='<tr><td">%s</td><td align="right">0.00</td></tr>'%(cstr(d[0]))
					else:
						ded_table +='<tr><td>%s</td><td align="right">%s</td></tr>'%(cstr(d[0]),cstr(d[1]))
				ded_table += '</table>'
			
			letter_head = sql("select value from `tabSingles` where field = 'letter_head' and doctype = 'Control Panel'")
			
			if not letter_head:
				letter_head = ''
			
			msg = '''<div> %s <br>
			<table cellspacing= "5" cellpadding="5"  width = "100%%">
				<tr>
					<td width = "100%%" colspan = "2"><h4>Salary Slip</h4></td>
				</tr>
				<tr>
					<td width = "50%%"><b>Employee Code : %s</b></td>
					<td width = "50%%"><b>Employee Name : %s</b></td>
				</tr>
				<tr>
					<td width = "50%%">Month : %s</td>
					<td width = "50%%">Fiscal Year : %s</td>
				</tr>
				<tr>
					<td width = "50%%">Department : %s</td>
					<td width = "50%%">Branch : %s</td>
				</tr>
				<tr>
					<td width = "50%%">Designation : %s</td>
					<td width = "50%%">Grade : %s</td>
				</tr>
				<tr>				
					<td width = "50%%">Bank Account No. : %s</td>
					<td  width = "50%%">Bank Name : %s</td>
				
				</tr>
				<tr>
					<td  width = "50%%">Arrear Amount : <b>%s</b></td>
					<td  width = "50%%">Payment days : %s</td>
				
				</tr>
			</table>
			<table border="1px solid #CCC" width="100%%" cellpadding="0px" cellspacing="0px">
				<tr>
					<td colspan = 2 width = "50%%" bgcolor="#CCC" align="center"><b>Earnings</b></td>
					<td colspan = 2 width = "50%%" bgcolor="#CCC" align="center"><b>Deductions</b></td>
				</tr>
				<tr>
					<td colspan = 2 width = "50%%" valign= "top">%s</td>
					<td colspan = 2 width = "50%%" valign= "top">%s</td>
				</tr>
			</table>
			<table cellspacing= "5" cellpadding="5" width = '100%%'>
				<tr>
					<td width = '25%%'><b>Gross Pay :</b> </td><td width = '25%%' align='right'>%s</td>
					<td width = '25%%'><b>Total Deduction :</b></td><td width = '25%%' align='right'> %s</td>
				</tr>
				<tr>
					<tdwidth='25%%'><b>Net Pay : </b></td><td width = '25%%' align='right'><b>%s</b></td>
					<td colspan = '2' width = '50%%'></td>
				</tr>
				<tr>
					<td width='25%%'><b>Net Pay(in words) : </td><td colspan = '3' width = '50%%'>%s</b></td>
				</tr>
			</table></div>'''%(cstr(letter_head[0][0]),cstr(self.doc.employee), cstr(self.doc.employee_name), cstr(self.doc.month), cstr(self.doc.fiscal_year), cstr(self.doc.department), cstr(self.doc.branch), cstr(self.doc.designation), cstr(self.doc.grade), cstr(self.doc.bank_account_no), cstr(self.doc.bank_name), cstr(self.doc.arrear_amount), cstr(self.doc.payment_days), earn_table, ded_table, cstr(flt(self.doc.gross_pay)), cstr(flt(self.doc.total_deduction)), cstr(flt(self.doc.net_pay)), cstr(self.doc.total_in_words))
			sendmail([receiver], sender='*****@*****.**', subject=subj, parts=[['text/plain', msg]])
		else:
			msgprint("Company Email ID not found.")
Esempio n. 37
0
	def send_mail_funct(self):	 
		emailid_ret=sql("select company_email from `tabEmployee` where name = '%s'"%self.doc.employee)
		if emailid_ret:
			receiver = cstr(emailid_ret[0][0]) 
			subj = 'Salary Slip - ' + cstr(self.doc.month) +'/'+cstr(self.doc.fiscal_year)
			earn_ret=sql("select e_type,e_modified_amount from `tabSS Earning Detail` where parent = '%s'"%self.doc.name)
			ded_ret=sql("select d_type,d_modified_amount from `tabSS Deduction Detail` where parent = '%s'"%self.doc.name)
		 
			earn_table = ''
			ded_table = ''
			if earn_ret:			
				earn_table += "<table cellspacing=5px cellpadding=5px width='100%%'>"
				
				for e in earn_ret:
					if not e[1]:
						earn_table +='<tr><td>%s</td><td align="right">0.00</td></tr>'%(cstr(e[0]))
					else:
						earn_table +='<tr><td>%s</td><td align="right">%s</td></tr>'%(cstr(e[0]),cstr(e[1]))
				earn_table += '</table>'
			
			if ded_ret:
			
				ded_table += "<table cellspacing=5px cellpadding=5px width='100%%'>"
				
				for d in ded_ret:
					if not d[1]:
						ded_table +='<tr><td">%s</td><td align="right">0.00</td></tr>'%(cstr(d[0]))
					else:
						ded_table +='<tr><td>%s</td><td align="right">%s</td></tr>'%(cstr(d[0]),cstr(d[1]))
				ded_table += '</table>'
			
			letter_head = sql("select value from `tabSingles` where field = 'letter_head' and doctype = 'Control Panel'")
			
			if not letter_head:
				letter_head = ''
			
			msg = '''<div> %s <br>
			<table cellspacing= "5" cellpadding="5"  width = "100%%">
				<tr>
					<td width = "100%%" colspan = "2"><h4>Salary Slip</h4></td>
				</tr>
				<tr>
					<td width = "50%%"><b>Employee Code : %s</b></td>
					<td width = "50%%"><b>Employee Name : %s</b></td>
				</tr>
				<tr>
					<td width = "50%%">Month : %s</td>
					<td width = "50%%">Fiscal Year : %s</td>
				</tr>
				<tr>
					<td width = "50%%">Department : %s</td>
					<td width = "50%%">Branch : %s</td>
				</tr>
				<tr>
					<td width = "50%%">Designation : %s</td>
					<td width = "50%%">Grade : %s</td>
				</tr>
				<tr>				
					<td width = "50%%">Bank Account No. : %s</td>
					<td  width = "50%%">Bank Name : %s</td>
				
				</tr>
				<tr>
					<td  width = "50%%">Arrear Amount : <b>%s</b></td>
					<td  width = "50%%">Payment days : %s</td>
				
				</tr>
			</table>
			<table border="1px solid #CCC" width="100%%" cellpadding="0px" cellspacing="0px">
				<tr>
					<td colspan = 2 width = "50%%" bgcolor="#CCC" align="center"><b>Earnings</b></td>
					<td colspan = 2 width = "50%%" bgcolor="#CCC" align="center"><b>Deductions</b></td>
				</tr>
				<tr>
					<td colspan = 2 width = "50%%" valign= "top">%s</td>
					<td colspan = 2 width = "50%%" valign= "top">%s</td>
				</tr>
			</table>
			<table cellspacing= "5" cellpadding="5" width = '100%%'>
				<tr>
					<td width = '25%%'><b>Gross Pay :</b> </td><td width = '25%%' align='right'>%s</td>
					<td width = '25%%'><b>Total Deduction :</b></td><td width = '25%%' align='right'> %s</td>
				</tr>
				<tr>
					<tdwidth='25%%'><b>Net Pay : </b></td><td width = '25%%' align='right'><b>%s</b></td>
					<td colspan = '2' width = '50%%'></td>
				</tr>
				<tr>
					<td width='25%%'><b>Net Pay(in words) : </td><td colspan = '3' width = '50%%'>%s</b></td>
				</tr>
			</table></div>'''%(cstr(letter_head[0][0]),cstr(self.doc.employee), cstr(self.doc.employee_name), cstr(self.doc.month), cstr(self.doc.fiscal_year), cstr(self.doc.department), cstr(self.doc.branch), cstr(self.doc.designation), cstr(self.doc.grade), cstr(self.doc.bank_account_no), cstr(self.doc.bank_name), cstr(self.doc.arrear_amount), cstr(self.doc.payment_days), earn_table, ded_table, cstr(flt(self.doc.gross_pay)), cstr(flt(self.doc.total_deduction)), cstr(flt(self.doc.net_pay)), cstr(self.doc.total_in_words))
			sendmail([receiver], sender='*****@*****.**', subject=subj, parts=[['text/plain', msg]])
		else:
			msgprint("Company Email ID not found.")
Esempio n. 38
0
	def send_mail_funct(self):	 
		emailid_ret=sql("select company_email from `tabEmployee` where name = '%s'"%self.doc.employee)
		if emailid_ret:
			receiver = cstr(emailid_ret[0][0]) 
			subj = 'Salary Slip ' + cstr(self.doc.month) +' '+cstr(self.doc.year)
			earn_ret=sql("select e_type,e_amount from `tabSS Earning Detail` where parent = '%s'"%self.doc.name)
			ded_ret=sql("select d_type,d_amount from `tabSS Deduction Detail` where parent = '%s'"%self.doc.name)
		 
			earn_table = ''
			ded_table = ''
			if earn_ret:
			
				earn_table += "<table cellspacing= '5' cellpadding='5' >"
				
				for e in earn_ret:
					if not e[1]:
						earn_table +='<tr><td>%s</td><td>0.00</td></tr>'%(cstr(e[0]))
					else:
						earn_table +='<tr><td>%s</td><td>%s</td></tr>'%(cstr(e[0]),cstr(e[1]))
				earn_table += '</table>'
			
			if ded_ret:
			
				ded_table += "<table cellspacing= '5' cellpadding='5' >"
				
				for d in ded_ret:
					if not d[1]:
						ded_table +='<tr><td>%s</td><td>0.00</td></tr>'%(cstr(d[0]))
					else:
						ded_table +='<tr><td>%s</td><td>%s</td></tr>'%(cstr(d[0]),cstr(d[1]))
				ded_table += '</table>'
			
			letter_head = sql("select value from `tabSingles` where field = 'letter_head' and doctype = 'Control Panel'")
			
			if not letter_head:
				letter_head = ''
			
			msg = ''' %s <br>
			<table cellspacing= "5" cellpadding="5" >
			<tr>
				<td colspan = 4><h4>Salary Slip</h4></td>
			</tr>
			<tr>
				<td colspan = 2><b>Employee Code : %s</b></td>
				<td colspan = 2><b>Employee Name : %s</b></td>
			</tr>
			<tr>
				<td>Month : %s</td>
				<td>Year : %s</td>
				<td colspan = 2>Fiscal Year : %s</td>
			</tr>
			<tr>
				<td>Department : %s</td>
				<td>Branch : %s</td>
				<td colspan = 2>Designation : %s</td>
				
			</tr>
			<tr>
				<td>Grade : %s</td>
				<td>Bank Account No. : %s</td>
				<td colspan = 2>Bank Name : %s</td>
				
			</tr>
			<tr>
				<td>PF No. : %s</td>
				<td>ESIC No. : %s</td>
				<td colspan = 2>Arrear Amount : <b>%s</b></td>
			</tr>
			<tr>
				<td>Total days in month : %s</td>
				<td>Leave Without Pay : %s</td>
				<td colspan = 2>Payment days : %s</td>
				
			</tr>
			<br><br>
			<tr>
				<td colspan = 2><b>Earning</b></td>
				<td colspan = 2><b>Deduction</b></td>
			</tr>
			<tr>
				<td colspan = 2>%s</td>
				<td colspan = 2>%s</td>
			</tr>
			<br>
			<tr>
				<td colspan = 2><b>Gross Pay :</b> %s</td>
				<td colspan = 2><b>Total Deduction :</b> %s</td>
			</tr>
			<tr>
				<td><b>Net Pay : %s</b></td>
				<td colspan = 3><b>Net Pay (in words) : %s</b></td>
			</tr>
			</table>'''%(cstr(letter_head[0][0]),cstr(self.doc.employee),self.doc.employee_name,cstr(self.doc.month),cstr(self.doc.year),cstr(self.doc.fiscal_year),self.doc.department,self.doc.branch,self.doc.designation,self.doc.grade,cstr(self.doc.bank_account_no),self.doc.bank_name,cstr(self.doc.pf_no),cstr(self.doc.esic_no),cstr(self.doc.arrear_amount),cstr(self.doc.total_days_in_month),cstr(self.doc.leave_without_pay),cstr(self.doc.payment_days),earn_table,ded_table,cstr(self.doc.gross_pay),cstr(self.doc.total_deduction),cstr(self.doc.net_pay),cstr(self.doc.net_pay_in_words))
			sendmail([receiver], sender='*****@*****.**', subject=subj, parts=[['text/plain', msg]])
		else:
			msgprint("Company Email ID not found.")
 def send_mail(self):
   send_to = [self.doc.allocated_to, self.doc.contact_email]
   msg = '''%s Complaint Note raised by %s.
         Refer Complaint Note : %s
         '''%(self.doc.call_type, self.doc.complaint_raised_by, self.doc.name)
   sendmail(send_to, sender = '*****@*****.**', subject = 'Complaint Note', parts=[['text/plain', msg]])
Esempio n. 40
0
	def send_feedback(self,name,message,sub):
		send = sql("select email_id from `tabSales Person` where name = %s",name)[0][0]
		msg = message
		sendmail(send, sender='*****@*****.**', subject=sub, parts=[['text/plain', msg]])
		msgprint("Feedback successfully sent to '%s'" %(name))