def getLocalReport(self, reqId):
		data = self.get_jasper_reqid_data(reqId)
		if not data['data']:
			frappe.throw(_("No report for this requestid %s." % reqId))
		output_path = data['data']['result'].get("uri")
		content = get_file(output_path, "rb")
		return content
	def prepare_report_async(self, path, doc, data=None, params=None, pformat="pdf", ncopies=1, for_all_sites=0):
		resps = []
		frappe.local.fds = None
		frappe.local.batch = None
		data = self.run_report_async(doc, data=data, params=params)
		"""
		Run one report at a time for Form type report and many ids
		"""
		if (doc.jasper_report_type == "Form" or data.get('jasper_report_type', None) == "Form") and not data.get("is_doctype_id", None):
			ids = data.get('ids', [])[:]
			for id in ids:
				data['ids'] = [id]
				resps.append(self._run_report_async(path, doc, data=data, params=params, pformat=pformat, ncopies=ncopies, for_all_sites=for_all_sites))
		else:
			resps.append(self._run_report_async(path, doc, data=data, params=params, pformat=pformat, ncopies=ncopies, for_all_sites=for_all_sites))

		if self.report_origin == "local":
			resps = resps[:1]
			frappe.local.batch.batchReport.export()
			if frappe.local.batch.outtype == 7:#html file
				content = get_file(frappe.local.batch.outputPath + os.sep + frappe.local.batch.reportName + ".html")
				self.copy_images(content, frappe.local.batch.outputPath + os.sep, frappe.local.batch.reportName, data.get("report_name"), frappe.local.site)

		cresp = self.prepareCollectResponse(resps)
		return cresp
Esempio n. 3
0
	def prepare_report_async(self, path, doc, data=None, params=None, pformat="pdf", ncopies=1, for_all_sites=0):
		resps = []
		frappe.local.fds = None
		frappe.local.batch = None
		data = self.run_report_async(doc, data=data, params=params)
		"""
		Run one report at a time for Form type report and many ids
		"""
		if (doc.jasper_report_type == "Form" or data.get('jasper_report_type', None) == "Form") and not data.get("is_doctype_id", None):
			ids = data.get('ids', [])[:]
			for id in ids:
				data['ids'] = [id]
				resps.append(self._run_report_async(path, doc, data=data, params=params, pformat=pformat, ncopies=ncopies, for_all_sites=for_all_sites))
		else:
			resps.append(self._run_report_async(path, doc, data=data, params=params, pformat=pformat, ncopies=ncopies, for_all_sites=for_all_sites))

		if self.report_origin == "local":
			resps = resps[:1]
			frappe.local.batch.batchReport.export()
			if frappe.local.batch.outtype == 7:#html file
				content = get_file(frappe.local.batch.outputPath + os.sep + frappe.local.batch.reportName + ".html")
				self.copy_images(content, frappe.local.batch.outputPath + os.sep, frappe.local.batch.reportName, data.get("report_name"), frappe.local.site)

		cresp = self.prepareCollectResponse(resps)
		return cresp
 def getLocalReport(self, reqId):
     data = self.get_jasper_reqid_data(reqId)
     if not data['data']:
         frappe.throw(_("No report for this requestid %s." % reqId))
     output_path = data['data']['result'].get("uri")
     content = get_file(output_path, "rb")
     return content
Esempio n. 5
0
def get_jasper_email_report(data):
    if not data:
        frappe.throw(_("There is no data for this Report."))
    data = json.loads(unquote(data))
    file_name = data.get("filename")
    file_path = data.get("filepath")
    jsr = jasper_session_obj or Jr.JasperRoot()
    try:
        output = get_file(file_path, modes="rb")
        jsr.prepare_file_to_client(file_name, output)
    except:
        frappe.throw(_("There is no %s report." % file_name))
def get_jasper_email_report(data):
	if not data:
		frappe.throw(_("There is no data for this Report."))
	data = json.loads(unquote(data))
	file_name = data.get("filename")
	file_path = data.get("filepath")
	jsr = jasper_session_obj or Jr.JasperRoot()
	try:
		output = get_file(file_path, modes="rb")
		jsr.prepare_file_to_client(file_name, output)
	except:
		frappe.throw(_("There is no %s report." % file_name))
	def prepare_report_async(self, path, doc, data=None, params=None, pformat="pdf", ncopies=1, for_all_sites=0):
		resps = []
		frappe.local.fds = None
		frappe.local.batch = None
		data = self.run_report_async(doc, data=data, params=params)
		"""
		Run one report at a time for Form type report and many ids
		"""
		if (doc.jasper_report_type == "Form" or data.get('jasper_report_type', None) == "Form") and not data.get("is_doctype_id", None):
			ids = data.get('ids', [])[:]
			for id in ids:
				data['ids'] = [id]
				resps.append(self._run_report_async(path, doc, data=data, params=params, pformat=pformat, ncopies=ncopies, for_all_sites=for_all_sites))
		else:
			resps.append(self._run_report_async(path, doc, data=data, params=params, pformat=pformat, ncopies=ncopies, for_all_sites=for_all_sites))

		if self.report_origin == "local":
			resps = resps[:1]
			cresp = self.prepareCollectResponse(resps)
			cresp["origin"] = "local"
			cresp["pformat"] = pformat
			self.frappe_task.setResult([cresp])
			frappe.local.batch.batchReport.export()
			if frappe.local.batch.outtype == 7:#html file
				content = get_file(frappe.local.batch.outputPath + os.sep + frappe.local.batch.reportName + ".html")
				self.copy_images(content, frappe.local.batch.outputPath + os.sep, frappe.local.batch.reportName, data.get("report_name"), frappe.local.site)
		else:
			cresp = self.prepareCollectResponse(resps)
			cresp["origin"] = "server"
			cresp["pformat"] = pformat
			#self.frappe_task.setResult([cresp])
			#self.frappe_task.setReadyTask()
			from frappe.async import emit_via_redis
			task_id = "Local-" + frappe.local.task_id
			response = {}
			response.update({
				"status": "Success",
				"task_id": task_id,
				"result": [cresp]
			})
			emit_via_redis("task_status_change", response, frappe.local.site + ":task_progress:" + task_id)

		return cresp