Passed
Pull Request — master (#1859)
by
unknown
46:36 queued 09:44
created

currency()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 2
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 1
nc 2
nop 1
dl 0
loc 2
rs 10
c 1
b 0
f 0
1
<?php
2
include_once INCLUDESPATH . "easyparliament/templates/html/mp/header.php";
3
?>
4
5
<style>
6
table {
7
  border-collapse: collapse;
8
}
9
10
td, th {
11
  max-width: 200px;
12
  word-wrap: break-word;
13
overflow: hidden;
14
word-wrap: break-word;
15
white-space: normal;
16
}
17
18
td.wrap {
19
  white-space: normal;
20
}
21
</style>
22
23
<?php
24
25
function currency($amount) {
26
    return '£' . (intval($amount) == $amount ? number_format($amount, 0) : number_format($amount, 2));
27
}
28
29
function humInt(int $num): string {
30
    $words = ['zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine'];
31
32
    return ($num >= 0 && $num < 10) ? $words[$num] : strval($num);
33
}
34
35
function asDf($value) {
36
    return $value;
37
}
38
39
?>
40
41
<div class="full-page">
42
    <div class="full-page__row">
43
        <div class="full-page__unit">
44
            <?php include '_person_navigation.php'; ?>
45
        </div>
46
        <div class="person-panels">
47
            <div class="sidebar__unit in-page-nav">
48
                <div>
49
50
                <h3 class="browse-content"><?= gettext('Browse content') ?></h3>
51
                <ul>
52
                        <li><a href="https://pages.mysociety.org/parl_register_interests/datasets/parliament_2024/latest">About WhoFundsThem</a></li>
53
                    </ul>                
54
                    <?php $election_registers = [$register_2024_enriched]; ?>
55
                    <?php foreach ($election_registers as $register) { ?>
56
                    <?php /** @var MySociety\TheyWorkForYou\DataClass\Regmem\Person $register */ ?>
57
58
                    <h3 class="browse-content"><?= $register->displayChamber() ?></h3>
59
                    <ul>
60
                            <?php foreach ($register->categories as $category) { ?>
61
                                <?php if ($category->only_null_entries()) { ?>
62
                                    <?php continue; ?>
63
                                <?php }; ?>
64
                                <li><a href="#category-<?= $register->chamber . $category->category_id ?>"><?= $category->category_name ?></a></li>
65
                            <?php }; ?>
66
                    </ul>
67
                    <?php }; ?>
68
69
                    <?php include '_featured_content.php'; ?>
70
                    <?php include '_donation.php'; ?>
71
                </div>
72
            </div>
73
74
            <div class="primary-content__unit">
75
76
                <?php if ($register_interests) { ?>
77
78
                    <?php /** @var MySociety\TheyWorkForYou\DataClass\Regmem\Person $register */ ?>
79
                    <?php foreach ($election_registers as $register) { ?>                        
80
                    <div class="panel register">
81
                    <a name="register"></a>
82
                    <h2>Enriched Election Register</h2>
83
                    
84
                        <p>This is an enriched version of the post-election September 2024 register of members' interests for any donations/support or gifts declared.</p>
85
                        We have worked with a group of volunteers to add additional context to the register, including:
86
                        <ul style="list-style-type: disc; padding-left: 20px;">
87
                            <li>Adding short descriptions/urls of organisations</li>
88
                            <li>Grouping organisations into categories</li>
89
                            <li>Identifying donors who have given to multiple MPs</li>
90
                            </ul>
91
                        <p>This is an experiment in new ways of summarising, enhancing and displaying the register. <a href="<?= $member_url ?>/register">View the standard version of the register</a>.</p>
92
                        <p>Read our <a href="http://research.mysociety.org/html/beyond-transparency/">Beyond Transparency report</a> for more information about the register and our recommendations for improving it.</p>
93
                            <hr>
94
                            <p>As part of this project we have also <a href="/highlighted-interests/2024">highlighted a set of interests</a> related to industries with low public support (gambling and oil/gas), or the governments of not free countries.
95
                            <?php if ($mp_has_highlighted_interests) { ?>
96
97
                            <p>This MP has <a href="/highlighted-interests/2024">a highlighted interest on that page</a>.</p>
98
                            <?php } else { ?>
99
                            <p>This MP does not have any highlighted interests on that page.</p>
100
                            </p>
101
                        <?php }; ?>
102
                    </div>
103
104
105
106
                        <?php if ($register->categories->isEmpty()) { ?>
107
                            <div class="panel register">
108
                                <p><?= ucfirst($full_name) ?> did not declare any relevant donations or gifts in the September 2024 register. </p>
109
                                <p>This means he did not declare any donations above £1,500 in value, or any gifts above £300 in value.</p>
110
                            </div>
111
                        <?php }; ?>
112
113
                        <?php foreach ($register->categories as $category) { ?>
114
                            <div class="panel register">    
115
                            <h2 id="category-<?= $register->chamber . $category->category_id ?>"><?= $category->category_name ?></h2>
116
117
118
                            <?php $summary = $category->summary_details("enriched_info"); ?>
119
                            <h3>Summary</h3>
120
121
                                <?php if ($summary["category_id"] == "2") { ?>
122
                                <p>Donations need to be declared if they are more than £1,500 in value (or if multiple donations of over £500 from the same source add up to more than £1,500) </p>
123
                                <p>As such, we can only show the breakdown of donations we know about. One of our recommendations is that MPs should declare an aggregate summary of donations below the threshold to fill in the context of large donations. </p>
124
                                <hr/>
125
                                <p>As of the September 2024 register, <?= ucfirst($full_name) ?> had declared <?= humInt($summary["items_count"]) ?> <?= make_plural("donation", $summary["items_count"]) ?> of money or support.</p>
126
127
                                <?php } elseif ($summary["category_id"] == "3") { ?>
128
                                    <p>Donations need to be declared if they are more than £300 in value (or are multiple benefits that add up to £300).</p>
129
                                    <p>One of our recommendations is to adopt a disclosure threshold in line with wider public sector / civil service thresholds (e.g. £20), and to consult and adopt new rules and guidance on when MPs should not accept gifts. </p>
130
                                    <hr/>
131
                                    <p>As of the September 2024 register <?= ucfirst($full_name) ?> had declared <?= humInt($summary["items_count"]) ?> <?= make_plural("gift", $summary["items_count"]) ?>.</p>
132
                                <?php }; ?>
133
                                
134
                                <p> Of these, <?= currency($summary["in_kind_sum"]) ?> was in kind, and <?= currency($summary["cash_sum"]) ?> was cash. </p>
135
136
                                <?php if (!($summary["single_mp_sum"] ?? null)) { ?>
137
                                    <p>In-kind <?= strtolower($summary["item_name"]) ?> are <?= strtolower($summary["item_name"]) ?> of goods or services, rather than cash.</p>
138
                                <?php }; ?>
139
140
                                <p> <?= currency($summary["individual_income"]) ?> came from private individuals, and <?= currency($summary["non_individual_income"]) ?> came from other sources.</p>
141
142
                                <?php if (isset($summary["single_mp_sum"])) { ?>
143
                                    <p><?= currency($summary["single_mp_sum"]) ?> came from private individuals unique to this MP and <?= currency($summary["multi_mp_sum"]) ?> came from private individuals who had also given to other MPs. </p>
144
                                <?php }; ?>
145
                                <h3>Source of <?= strtolower($summary["item_name"]) ?></h3>
146
147
                                <p>The following table shows the split between the sources of <?= strtolower($summary["item_name"]) ?>, and whether they are cash or in-kind <?= strtolower($summary["item_name"]) ?>.</p>
148
149
150
                                <?= $summary["source_pivot"] ?>
151
152
                                <h3><?= $summary["item_name"] ?> from organisations</h3>
153
154
                                <?php if ($summary["org_table"] ?? null) { ?>
155
156
                                <p>We have grouped organisations into a set of common categories.</p>
157
                                    
158
                                <p>Here is a summary of the kinds of organisations that donated to <?= ucfirst($full_name) ?>.</p>
159
160
                                <?= $summary["org_group_pivot"] ?>
161
162
                                <h4>Details</h4>
163
                                <?= $summary["org_table"] ?>
164
                                <?php } else { ?>
165
166
                                <p>No <?= strtolower($summary["item_name"]) ?> were from organisations.</p>
167
168
                                <?php }; ?>
169
170
                                <h3><?= $summary["item_name"] ?> from individuals</h3>
171
172
                                <?php if ($summary["multi_pivot"] ?? null) { ?>
173
                                <p>Most donors only donate to a single MP, but a small number of donors donate to multiple MPs.</p>
174
                                <p>Here is a summary of the <?= $summary["item_name"] ?> from individuals to <?= ucfirst($full_name) ?>.</p>
175
176
                                <?= $summary["multi_pivot"] ?>
177
178
                                <h4>Details</h4>
179
180
                                <?= $summary["individual_table"] ?>
181
182
                                <?php } else { ?>
183
184
                                <p>No registered <?= strtolower($summary["item_name"]) ?> were from individuals.</p>
185
186
                                <?php }; ?>
187
188
189
190
                                </div>
191
                        
192
                        <?php }; ?>
193
                    
194
                    <?php }; ?>
195
196
197
                <?php }; ?>
198
199
                <?php include('_profile_footer.php'); ?>
200
201
            </div>
202
        </div>
203
    </div>
204
</div>
205