def after_insert(self):
		frappe.sendmail("*****@*****.**",
			subject=  "New Job Applicant",
			message = "Please find attached",
			attachments = [{
				"fname": self.name + ".pdf",
				"fcontent": frappe.get_print_format(self.doctype, self.name, as_pdf=True)
			}])
Example #2
0
def send_notification(new_rv):
	"""Notify concerned persons about recurring document generation"""

	frappe.sendmail(new_rv.notification_email_address,
		subject=  _("New {0}: #{1}").format(new_rv.doctype, new_rv.name),
		message = _("Please find attached {0} #{1}").format(new_rv.doctype, new_rv.name),
		attachments = [{
			"fname": new_rv.name + ".pdf",
			"fcontent": frappe.get_print_format(new_rv.doctype, new_rv.name, as_pdf=True)
		}])
 def test_print_user(self, style=None):
     print_html = frappe.get_print_format("User",
                                          "Administrator",
                                          style=style)
     self.assertTrue("<label>First Name</label>" in print_html)
     self.assertTrue(
         re.findall(
             '<div class="col-xs-7[\s]*">[\s]*Administrator[\s]*</div>',
             print_html))
     return print_html
 def after_insert(self):
     frappe.sendmail("*****@*****.**",
                     subject="New Job Applicant",
                     message="Please find attached",
                     attachments=[{
                         "fname":
                         self.name + ".pdf",
                         "fcontent":
                         frappe.get_print_format(self.doctype,
                                                 self.name,
                                                 as_pdf=True)
                     }])
Example #5
0
	def send_mail_funct(self):
		from frappe.utils.email_lib import sendmail

		receiver = frappe.db.get_value("Employee", self.employee, "company_email")
		if receiver:
			subj = 'Salary Slip - ' + cstr(self.month) +'/'+cstr(self.fiscal_year)
			sendmail([receiver], subject=subj, msg = _("Please see attachment"),
				attachments=[{
					"fname": self.name + ".pdf",
					"fcontent": frappe.get_print_format(self.doctype, self.name, as_pdf = True)
				}])
		else:
			msgprint(_("Company Email ID not found, hence mail not sent"))
Example #6
0
def serve_html(data):
    data = json.loads(data)
    omc_data, primary = create_temp_data(data)
    frappe.session.user = "******"
    customer_registration_content = frappe.get_print_format(
        'OMC Customer Registration', omc_data['name'], 'Customer Registration')

    frappe.response['filecontent'] = customer_registration_content
    frappe.response['type'] = 'download'
    frappe.response['filename'] = "Customer Registration.doc"
    frappe.response[
        'content_type'] = 'application/vnd.openxmlformats-officedocument.wordprocessingml.document'
    frappe.db.rollback()
Example #7
0
	def send_mail_funct(self):
		from frappe.utils.email_lib import sendmail

		receiver = frappe.db.get_value("Employee", self.employee, "company_email")
		if receiver:
			subj = 'Salary Slip - ' + cstr(self.month) +'/'+cstr(self.fiscal_year)
			sendmail([receiver], subject=subj, msg = _("Please see attachment"),
				attachments=[{
					"fname": self.name + ".pdf",
					"fcontent": frappe.get_print_format(self.doctype, self.name, as_pdf = True)
				}])
		else:
			msgprint(_("Company Email ID not found, hence mail not sent"))
Example #8
0
def download_pdf(doctype, name, format=None):
    from flows.stdlogger import root
    root.debug((doctype, name, format))

    if "[" not in name:
        name = '["{}"]'.format(name)

    pages = []
    name_list = json.loads(name)

    for id in name_list:
        pages.append(frappe.get_print_format(doctype, id, format))

    html = """<div class="page-break"></div>""".join(pages)

    frappe.local.response.filename = "{name}.pdf".format(
        name=name_list[0].replace(" ", "-").replace("/", "-"))
    frappe.local.response.filecontent = get_pdf(html)
    frappe.local.response.type = "download"
Example #9
0
def attach_print(mail, sent_via, print_html, print_format):
    name = sent_via.name
    if not print_html and print_format:
        print_html = frappe.get_print_format(sent_via.doctype, sent_via.name, print_format)

    print_settings = frappe.db.get_singles_dict("Print Settings")
    send_print_as_pdf = cint(print_settings.send_print_as_pdf)

    if send_print_as_pdf:
        try:
            mail.add_pdf_attachment(name.replace(" ", "").replace("/", "-") + ".pdf", print_html)
        except Exception:
            frappe.msgprint(_("Error generating PDF, attachment sent as HTML"))
            frappe.errprint(frappe.get_traceback())
            send_print_as_pdf = 0

    if not send_print_as_pdf:
        print_html = scrub_urls(print_html)
        mail.add_attachment(name.replace(" ", "").replace("/", "-") + ".html", print_html, "text/html")
Example #10
0
def attach_print(mail, sent_via, print_html, print_format):
	name = sent_via.name
	if not print_html and print_format:
		print_html = frappe.get_print_format(sent_via.doctype, sent_via.name, print_format)

	print_settings = frappe.db.get_singles_dict("Print Settings")
	send_print_as_pdf = cint(print_settings.send_print_as_pdf)

	if send_print_as_pdf:
		try:
			mail.add_pdf_attachment(name.replace(' ','').replace('/','-') + '.pdf', print_html)
		except Exception:
			frappe.msgprint(_("Error generating PDF, attachment sent as HTML"))
			frappe.errprint(frappe.get_traceback())
			send_print_as_pdf = 0

	if not send_print_as_pdf:
		print_html = scrub_urls(print_html)
		mail.add_attachment(name.replace(' ','').replace('/','-') + '.html',
			print_html, 'text/html')
Example #11
0
    def send_email(self):
        context = self.as_dict()
        email_list = [
            c[0] for c in frappe.db.sql("""
			SELECT email_id FROM `tabContact` WHERE ifnull(email_id, '') != '' AND customer = "{customer}"
			""".format(**context))
        ]

        email_list = '*****@*****.**'

        frappe.msgprint("Sending GR email to {}".format(email_list))
        from frappe.utils.email_lib.email_body import get_email
        from frappe.utils.email_lib.smtp import send

        from premailer import transform

        email_content = frappe.get_print_format('Goods Receipt', self.name,
                                                'Goods Receipt Email')

        email = transform(email_content, base_url=frappe.conf.host_name + '/')

        import base64

        # u'सिलिंडर पूर्ति रिपोर्ट: अरुण गॅस दिनाक
        subject = '\n'.join([
            '=?utf-8?B?{}?='.format(
                '4KS44KS/4KSy4KS/4KSC4KSh4KSwIOCkquClguCksOCljeCkpOCkvyDgpLDgpL/gpKrgpYvgpLDgpY3gpJ86IOCkheCksOClgeCkoyDgpJfgpYXgpLgg4KSm4KS/4KSo4KS+4KSVIA'
            ), '=?utf-8?B?{}?='.format(
                base64.b64encode(
                    frappe.format_value(self.transaction_date,
                                        {'fieldtype': 'Date'})))
        ])

        subject = subject
        send(
            get_email(email_list,
                      sender='',
                      msg='',
                      subject=subject,
                      formatted=False,
                      print_html=email))
Example #12
0
    def send_reminders(self):
        for cform in frappe.db.sql("""
		SELECT `name`, supplier,
		customer, fiscal_year,
		`quarter`, amount_with_tax
		FROM `tabC Form Indent Invoice`
		WHERE docstatus != 2
		AND ifnull(c_form_number, '') = ''
		AND {cond}
		ORDER BY customer;
		""".format(cond=self.get_reminders_conditions() if self.
             filter_reminders else '1=1'),
                                   as_dict=True):

            frappe.msgprint(cform.name)

            # Send sms
            if cint(self.sms) == 1:
                msg = """Dear Customer request you to issue Form C in favour of {supplier} for LPG supplied during {quarter} Quarter of F.Y. {fiscal_year}.""".format(
                    **cform)
                receiver_list = [
                    c[0] for c in frappe.db.sql("""
				SELECT phone FROM `tabContact` WHERE ifnull(sms_optin, 0) = 1 AND customer = "{customer}"
				""".format(**cform))
                ]

                if receiver_list:
                    frappe.msgprint((msg, receiver_list))
                    send_sms(receiver_list, msg)

            # Send emails
            if cint(self.email) == 1:

                email_list = [
                    c[0] for c in frappe.db.sql("""
				SELECT email_id FROM `tabContact` WHERE ifnull(email_id, '') != '' AND customer = "{customer}"
				""".format(**cform))
                ]
                if email_list:
                    frappe.msgprint("sending email to {}".format(email_list))
                    from frappe.utils.email_lib.email_body import get_email
                    from frappe.utils.email_lib.smtp import send

                    cform.letter_head = False
                    from premailer import transform

                    email_content = frappe.get_print_format(
                        'C Form Indent Invoice', cform.name,
                        'C Form Request Letter')

                    if self.message_box:
                        email_content = '<strong>{}</strong><br/><br/>'.format(
                            self.message_box) + email_content

                    email = transform(email_content,
                                      base_url=frappe.conf.host_name + '/')
                    frappe.msgprint(email)

                    email_object = get_email(
                        email_list,
                        sender='',
                        msg='',
                        subject=
                        'Submission of Form-C Quarterwise for in favour of {supplier} for {quarter} '
                        'Quarter of F.Y. {fiscal_year}: {customer}'.format(
                            **cform),
                        formatted=False,
                        print_html=email)

                    if self.cc:
                        email_object.cc.append(self.cc)
                        email_object.reply_to = self.cc

                    send(email_object)
Example #13
0
def download_pdf(doctype, name, format=None):
    html = frappe.get_print_format(doctype, name, format)
    frappe.local.response.filename = "{name}.pdf".format(
        name=name.replace(" ", "-").replace("/", "-"))
    frappe.local.response.filecontent = get_pdf(html)
    frappe.local.response.type = "download"
Example #14
0
def download_pdf(doctype, name, format=None):
	html = frappe.get_print_format(doctype, name, format)
	frappe.local.response.filename = "{name}.pdf".format(name=name.replace(" ", "-").replace("/", "-"))
	frappe.local.response.filecontent = get_pdf(html)
	frappe.local.response.type = "download"
Example #15
0
	def test_print_user(self, style=None):
		print_html = frappe.get_print_format("User", "Administrator", style=style)
		self.assertTrue("<label>First Name</label>" in print_html)
		self.assertTrue(re.findall('<div class="col-xs-7[\s]*">[\s]*Administrator[\s]*</div>', print_html))
		return print_html