Passed
Pull Request — master (#1859)
by
unknown
09:35 queued 04:32
created

humInt()   A

Complexity

Conditions 3
Paths 4

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

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