Skip to content

Commit 9497727

Browse files
committed
feat(report def): Add LedgerAllocation output XSL
1 parent fc3c088 commit 9497727

File tree

1 file changed

+123
-0
lines changed

1 file changed

+123
-0
lines changed
Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
<?php
2+
declare(strict_types=1);
3+
4+
use UzerpPhinx\UzerpMigration;
5+
6+
final class LedgerAllocationReportDef extends UzerpMigration
7+
{
8+
public function up()
9+
{
10+
$xsl = <<<'UPDOC'
11+
<?xml version="1.0" encoding="utf-8"?>
12+
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format" version="1.0">
13+
<xsl:template match="/">
14+
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
15+
<fo:layout-master-set>
16+
<fo:simple-page-master master-name="all-pages"
17+
page-height="21cm"
18+
page-width="29.7cm"
19+
margin="1cm" >
20+
<fo:region-body margin-top="1cm" margin-bottom="1.1cm"/>
21+
<fo:region-before extent="1cm"/>
22+
<fo:region-after extent="5mm"/>
23+
</fo:simple-page-master>
24+
</fo:layout-master-set>
25+
<!-- format is the style of page numbering, 1 for 1,2,3, i for roman numerals (sp?)-->
26+
<fo:page-sequence master-reference="all-pages" format="1">
27+
<!-- header with running glossary entries -->
28+
<fo:static-content flow-name="xsl-region-before">
29+
<fo:block>Allocations</fo:block>
30+
</fo:static-content>
31+
<fo:static-content flow-name="xsl-region-after">
32+
<fo:block>Page <!--[page_position]--></fo:block>
33+
</fo:static-content>
34+
<fo:flow flow-name="xsl-region-body" >
35+
<fo:table table-layout="fixed" width="100%" font-size="8pt">
36+
<fo:table-column column-width="proportional-column-width(150)"/>
37+
<fo:table-column column-width="proportional-column-width(100)"/>
38+
<fo:table-column column-width="proportional-column-width(100)"/>
39+
<fo:table-column column-width="proportional-column-width(100)"/>
40+
<fo:table-column column-width="proportional-column-width(100)"/>
41+
<fo:table-column column-width="proportional-column-width(50)"/>
42+
<fo:table-column column-width="proportional-column-width(100)"/>
43+
<fo:table-column column-width="proportional-column-width(150)"/>
44+
<fo:table-column column-width="proportional-column-width(100)"/>
45+
<fo:table-header>
46+
<fo:table-row border-bottom-style ="solid" font-weight="bold">
47+
<xsl:attribute name="background-color"><!--[table_header_colour]--></xsl:attribute>
48+
<fo:table-cell padding="1mm">
49+
<fo:block>Company</fo:block>
50+
</fo:table-cell>
51+
<fo:table-cell padding="1mm">
52+
<fo:block>Transaction Date</fo:block>
53+
</fo:table-cell>
54+
<fo:table-cell padding="1mm">
55+
<fo:block>Transaction Type</fo:block>
56+
</fo:table-cell>
57+
<fo:table-cell padding="1mm">
58+
<fo:block>Our Ref</fo:block>
59+
</fo:table-cell>
60+
<fo:table-cell padding="1mm">
61+
<fo:block>Ext Ref</fo:block>
62+
</fo:table-cell>
63+
<fo:table-cell padding="1mm">
64+
<fo:block>Currency</fo:block>
65+
</fo:table-cell>
66+
<fo:table-cell padding="1mm">
67+
<fo:block text-align="right">Gross Value</fo:block>
68+
</fo:table-cell>
69+
<fo:table-cell padding="1mm">
70+
<fo:block text-align="right">Allocation Date</fo:block>
71+
</fo:table-cell>
72+
<fo:table-cell padding="1mm">
73+
<fo:block text-align="right">Payment Value</fo:block>
74+
</fo:table-cell>
75+
</fo:table-row>
76+
</fo:table-header>
77+
<fo:table-body>
78+
<xsl:for-each select="data/*">
79+
<fo:table-row>
80+
<!-- this condition is to provide us with alternate row colours -->
81+
<xsl:if test="(position() mod 2 = 1)">
82+
<xsl:attribute name="background-color"><!--[table_row_alternate_colour]--></xsl:attribute>
83+
</xsl:if>
84+
<xsl:variable name="company" select="supplier"/>
85+
<xsl:choose>
86+
<xsl:when test="$company != ''''">
87+
<fo:table-cell padding="1mm"><fo:block><xsl:value-of select="supplier" /></fo:block></fo:table-cell>
88+
</xsl:when>
89+
<xsl:otherwise>
90+
<fo:table-cell padding="1mm"><fo:block><xsl:value-of select="customer" /></fo:block></fo:table-cell>
91+
</xsl:otherwise>
92+
</xsl:choose>
93+
<fo:table-cell padding="1mm"><fo:block><xsl:value-of select="transaction_date" /></fo:block></fo:table-cell>
94+
<fo:table-cell padding="1mm"><fo:block><xsl:value-of select="transaction_type" /></fo:block></fo:table-cell>
95+
<fo:table-cell padding="1mm"><fo:block><xsl:value-of select="our_reference" /></fo:block></fo:table-cell>
96+
<fo:table-cell padding="1mm"><fo:block><xsl:value-of select="ext_reference" /></fo:block></fo:table-cell>
97+
<fo:table-cell padding="1mm"><fo:block><xsl:value-of select="currency" /></fo:block></fo:table-cell>
98+
<fo:table-cell padding="1mm"><fo:block text-align="right"><xsl:value-of select="gross_value" /></fo:block></fo:table-cell>
99+
<fo:table-cell padding="1mm"><fo:block text-align="right"><xsl:value-of select="allocation_date" /></fo:block></fo:table-cell>
100+
<fo:table-cell padding="1mm"><fo:block text-align="right"><xsl:value-of select="payment_value" /></fo:block></fo:table-cell>
101+
</fo:table-row>
102+
</xsl:for-each>
103+
</fo:table-body>
104+
</fo:table>
105+
<!-- this is required to calculate the last page number -->
106+
<fo:block id="last-page"/>
107+
</fo:flow>
108+
</fo:page-sequence>
109+
</fo:root>
110+
</xsl:template>
111+
</xsl:stylesheet>
112+
UPDOC;
113+
$date = new DateTime();
114+
$update_time = $date->format('Y-m-d H:i:s.u');
115+
$result = $this->query("INSERT INTO report_definitions (name, definition, lastupdated, alteredby, usercompanyid) VALUES ('LedgerAllocation', '{$xsl}', '{$update_time}', 'phinx', '1')");
116+
}
117+
118+
public function down()
119+
{
120+
$result = $this->query("DELETE FROM report_definitions WHERE name='LedgerAllocation'");
121+
}
122+
}
123+

0 commit comments

Comments
 (0)