def addCompanyInformation(self, document): company = self.session.company t = lambda txt: translate(txt, context=self.request) section = createSection( document, self.context, self.session, self.request) normal_style = document.StyleSheet.ParagraphStyles.Normal missing = t(_("missing_data", default=u"Not provided")) section.append(Paragraph( document.StyleSheet.ParagraphStyles.Heading1, t(_("plan_report_company_header", default=u"Company details")))) table = Table(TabPropertySet.DEFAULT_WIDTH * 3, TabPropertySet.DEFAULT_WIDTH * 8) field = CompanySchema["country"] country = self.request.locale.displayNames.territories.get( company.country.upper(), company.country) \ if company.country else missing table.append( Cell(Paragraph(normal_style, t(field.title))), Cell(Paragraph(normal_style, country))) field = CompanySchema["employees"] table.append( Cell(Paragraph(normal_style, t(field.title))), Cell(Paragraph( normal_style, t(field.vocabulary.getTerm(company.employees).title) if company.employees else missing))) field = CompanySchema["conductor"] table.append( Cell(Paragraph(normal_style, t(field.title))), Cell(Paragraph( normal_style, t(field.vocabulary.getTerm(company.conductor).title) if company.conductor else missing))) field = CompanySchema["referer"] table.append( Cell(Paragraph(normal_style, t(field.title))), Cell(Paragraph( normal_style, t(field.vocabulary.getTerm(company.referer).title) if company.referer else missing))) field = CompanySchema["workers_participated"] if company.workers_participated: term = field.vocabulary.getTerm(company.workers_participated) table.append( Cell(Paragraph(normal_style, t(field.title))), Cell(Paragraph( normal_style, t(term.title) if company.workers_participated else missing))) section.append(table)
def addMeasure(self, document, section, measure): normal_style = document.StyleSheet.ParagraphStyles.Normal t = lambda txt: translate(txt, context=self.request) table = Table(TabPropertySet.DEFAULT_WIDTH * 5, TabPropertySet.DEFAULT_WIDTH * 8) if measure.action_plan: table.append( Cell(Paragraph( normal_style, t(_("report_measure_actionplan", default=u"Action plan:")))), Cell(Paragraph(normal_style, measure.action_plan))) if measure.prevention_plan: table.append( Cell(Paragraph(normal_style, t(_("report_measure_preventionplan", default=u"Prevention plan:")))), Cell(Paragraph(normal_style, measure.prevention_plan))) if measure.requirements: table.append( Cell(Paragraph( normal_style, t(_("report_measure_requirements", default=u"Requirements:")))), Cell(Paragraph(normal_style, measure.requirements))) if table.Rows: section.append(table) if measure.responsible and not \ (measure.planning_start or measure.planning_end): section.append(Paragraph( normal_style, t(_("report_measure_responsible", default=u"${responsible} is responsible for this task.", mapping={"responsible": measure.responsible})))) elif measure.responsible and measure.planning_start and \ not measure.planning_end: section.append(Paragraph( normal_style, t(_("report_measure_responsible_and_start", default=u"${responsible} is responsible for this task " u"which starts on ${start}.", mapping={"responsible": measure.responsible, "start": formatDate(self.request, measure.planning_start)})))) elif measure.responsible and \ not measure.planning_start and measure.planning_end: section.append(Paragraph( normal_style, t(_("report_measure_responsible_and_end", default=u"${responsible} is responsible for this task " u"which ends on ${end}.", mapping={"responsible": measure.responsible, "end": formatDate(self.request, measure.planning_end)})))) elif measure.responsible and \ measure.planning_start and measure.planning_end: section.append(Paragraph( normal_style, t(_("report_measure_full", default=u"${responsible} is responsible for this task " u"which starts on ${start} and ends on ${end}.", mapping={"responsible": measure.responsible, "start": formatDate(self.request, measure.planning_start), "end": formatDate(self.request, measure.planning_end)})))) elif not measure.responsible and \ measure.planning_start and not measure.planning_end: section.append(Paragraph( normal_style, t(_("report_measure_start_only", default=u"This task starts on ${start}.", mapping={"start": formatDate( self.request, measure.planning_start)})))) elif not measure.responsible and \ not measure.planning_start and measure.planning_end: section.append(Paragraph( normal_style, t(_("report_measure_end_only", default=u"This task ends on ${end}.", mapping={"end": formatDate(self.request, measure.planning_end)})))) elif not measure.responsible \ and measure.planning_start and measure.planning_end: section.append(Paragraph( normal_style, t(_("report_measure_start_and_stop", default=u"This task starts on ${start} and ends on " u"${end}.", mapping={"start": formatDate(self.request, measure.planning_start), "end": formatDate(self.request, measure.planning_end)})))) if measure.budget: section.append(Paragraph( normal_style, t(_("report_measure_budget", default=u"There is a budget of ${amount} for " u"this measure.", mapping={"amount": measure.budget}))))
def addCompanyInformation(self, document): request=self.request company=self.session.dutch_company t=lambda txt: translate(txt, context=request) section = createSection(document, self.context, self.session, self.request) normal_style=document.StyleSheet.ParagraphStyles.Normal missing=t(eu_("missing_data", default=u"Not provided")) section.append(Paragraph( document.StyleSheet.ParagraphStyles.Heading1, t(eu_("plan_report_company_header", default=u"Company details")))) table=Table(TabPropertySet.DEFAULT_WIDTH*3, TabPropertySet.DEFAULT_WIDTH*8) field=DutchCompanySchema["title"] table.append( Cell(Paragraph(normal_style, str(field.title))), Cell(Paragraph(normal_style, company.title if company.title else missing))) address=formatAddress(company.address_visit_address, company.address_visit_postal, company.address_visit_city) table.append( Cell(Paragraph(normal_style, "Bezoekadres bedrijf")), Cell(Paragraph(normal_style, address if address else missing))) address=formatAddress(company.address_postal_address, company.address_postal_postal, company.address_postal_city) table.append( Cell(Paragraph(normal_style, "Postadres bedrijf")), Cell(Paragraph(normal_style, address if address else missing))) for key in ["email", "phone", "activity", "submitter_name", "submitter_function", "department", "location"]: field=DutchCompanySchema[key] value=getattr(company, key, None) table.append( Cell(Paragraph(normal_style, field.title)), Cell(Paragraph(normal_style, value if value else missing))), formatDecimal=request.locale.numbers.getFormatter("decimal").format field=DutchCompanySchema["absentee_percentage"] table.append( Cell(Paragraph(normal_style, field.title)), Cell(Paragraph(normal_style, u"%s %%" % formatDecimal(company.absentee_percentage) if company.absentee_percentage else missing))) for key in [ "accidents", "incapacitated_workers"]: field=DutchCompanySchema[key] value=getattr(company, key, None) table.append( Cell(Paragraph(normal_style, field.title)), Cell(Paragraph(normal_style, "%d" % value if value is not None else missing))) field=DutchCompanySchema["submit_date"] table.append( Cell(Paragraph(normal_style, field.title)), Cell(Paragraph(normal_style, formatDate(request, company.submit_date) if company.submit_date else missing))) field=DutchCompanySchema["employees"] table.append( Cell(Paragraph(normal_style, field.title)), Cell(Paragraph(normal_style, field.vocabulary.getTerm(company.employees).title if company.employees else missing))) field=DutchCompanySchema["arbo_expert"] table.append( Cell(Paragraph(normal_style, str(field.title))), Cell(Paragraph(normal_style, company.arbo_expert if company.arbo_expert else missing))) section.append(table)