Exemple #1
0
def html_snapshot(page):
	"""get html snapshot for search bot"""
	from webnotes.widgets.page import get_page_html	
	from webnotes.model.doc import Document

	doc = Document('Website Settings', 'Website Settings')
	doc.content = get_page_html(page)
	doc.header_menu = doc.footer_menu = ''
	doc.page_name = page
	
	for m in webnotes.conn.sql("""select parentfield, label, url, custom_page
		from `tabTop Bar Item` where parent='Top Bar Settings' order by idx""", as_dict=1):
	
		m['std_page'] = m.get('url') or m('custom_page')

		if m['parentfield']=='top_bar_items':				
			doc.header_menu += '<li><a href="index.cgi#!%(std_page)s">%(label)s</a></li>' % m
		else:
			doc.footer_menu += '<li><a href="index.cgi#!%(std_page)s">%(label)s</a></li>' % m
	
	return """
	<header>
		<h3>%(brand_html)s</h3>
		<ul>
			%(header_menu)s
		</ul>
	</header>
	%(content)s
	<footer>
		<ul>
			%(footer_menu)s
		</ul>
		<div>Address: %(address)s</div>
		<div>&copy; %(copyright)s</div>
		<div>Powered by <a href="https://erpnext.com">erpnext.com</a></div>
		<div style="background-color: #ffc; padding: 7px">
			This page is for search engines, for standard browsers click 
			<a href="index.cgi#!%(page_name)s">here</a>
		</div>
	</footer>
	""" % doc.fields
	def get_leadcomm_detail(self):
		check_communication_exist=webnotes.conn.sql("select name from `tabCommunication` where parent='%s'"%(self.doc.name))
		if not check_communication_exist:
			if self.doc.lead:
				res=webnotes.conn.sql("select name from `tabCommunication` where parent='%s'"%(self.doc.lead))
				for name in res:
					#webnotes.errprint(name)
				 	content=webnotes.conn.sql("select * from `tabCommunication` where name='%s'"%(name[0]),as_dict=1)
					if content:
						for data in content:
							d=Document('Communication')
							d.content=data.content
							d.parent=self.doc.name
							d.parenttype='Opportunity'
							d.idx=data.idx
							d.docstatus=data.docstatus
							d.parentfield=data.parentfield
							d.sender=data.sender
							d.recipients=data.recipients
							d.sent_or_received=data.sent_or_received
							d.communication_medium=data.communication_medium
							d.subject=data.subject
							d.save()