diff --git a/www/docs/mp/index.php b/www/docs/mp/index.php index 3056ab2489..78abc1307e 100644 --- a/www/docs/mp/index.php +++ b/www/docs/mp/index.php @@ -441,10 +441,22 @@ if ( $policyID ) { $data['policydivisions'] = $divisions->getMemberDivisionsForPolicy($policyID); + $rel_agreements = $policiesList->all_policy_agreements[$policyID]; + // filter down to where 'date' is within the member's term + // This won't be perfect where the member has been in and out of the house + // But it doesn't affect their score. + $rel_agreements = array_filter($rel_agreements, function($agreement) use ($MEMBER) { + return $MEMBER->date_in_memberships(HOUSE_TYPE_COMMONS, $agreement['date']); + }); + $data['policyagreements'] = array($policyID => $rel_agreements); } else { $data['policydivisions'] = $divisions->getAllMemberDivisionsByPolicy(); + $data['policyagreements'] = $policiesList->all_policy_agreements; } + + + // Send the output for rendering MySociety\TheyWorkForYou\Renderer::output('mp/divisions', $data); @@ -1157,7 +1169,7 @@ function person_party_policy_diffs($MEMBER, $policiesList, $only_diffs) { $policySummaries = $divisions->getMemberDivisionDetails(); $party = new MySociety\TheyWorkForYou\Party($MEMBER->party()); - $partyCohort = new MySociety\TheyWorkForYou\PartyCohort($MEMBER->cohortKey()); + $partyCohort = new MySociety\TheyWorkForYou\PartyCohort($MEMBER->person_id(), $MEMBER->cohortParty()); $data['party_positions'] = $partyCohort->getAllPolicyPositions($policiesList); # house hard coded as this is only used for the party position # comparison which is Commons only diff --git a/www/includes/easyparliament/member.php b/www/includes/easyparliament/member.php index 193fddd38d..991d355a11 100644 --- a/www/includes/easyparliament/member.php +++ b/www/includes/easyparliament/member.php @@ -15,6 +15,7 @@ class MEMBER { public $party; public $other_parties = array(); public $other_constituencies; + public $memberships = array(); public $houses = array(); public $entered_house = array(); public $left_house = array(); @@ -165,6 +166,8 @@ public function __construct($args) { if (!in_array($house, $this->houses)) { $this->houses[] = $house; } + # add the entire row into the memberships array + $this->memberships[] = $row; $const = $row['constituency'] ? gettext($row['constituency']) : ''; $party = $row['party'] ? gettext($row['party']) : ''; $entered_house = $row['entered_house']; @@ -227,6 +230,17 @@ public function __construct($args) { $this->set_users_mp(); } + public function date_in_memberships($house, $date){ + // Given a date, see if they had any memberships during that time + foreach ($this->memberships as $membership) { + if ($membership['entered_house'] <= $date && $membership['left_house'] >= $date) { + if ($membership['house'] == $house) { + return true; + } } + } + return false; + } + public function member_id_to_person_id($member_id) { $q = $this->db->query("SELECT person_id FROM member WHERE member_id = :member_id", diff --git a/www/includes/easyparliament/templates/html/mp/_agreement_description.php b/www/includes/easyparliament/templates/html/mp/_agreement_description.php new file mode 100644 index 0000000000..063ad17e9d --- /dev/null +++ b/www/includes/easyparliament/templates/html/mp/_agreement_description.php @@ -0,0 +1,7 @@ +
Agreements are when Parliament takes a decision without holding a vote.
+This does not necessarily mean universal approval, but does mean there were no objections made to the decision being made
+ + +The following agreements were made while this member was elected:
+No scoring agreements are part of this policy while this member was elected.
+Agreements are when Parliament takes a decision without holding a vote.
+This may or may not mean universal approval, but does mean there were no objections made to the decision being made.
+ + +No informative agreements are part of this policy while this member was elected.
+