public function getDetails() { $stuff = array(); if ($amount = LsNumber::makeReadable($this->Relationship->amount, '$')) { $stuff[] = $amount; } if ($this->Relationship->goods) { $stuff[] = $this->Relationship->goods; } return implode(', ', $stuff); }
public function getDetails() { $details = array(); if ($this->percent_stake) { $details[] = $this->percent_stake . '% stake'; } if ($this->shares) { $details[] = LsNumber::makeReadable($this->shares) . ' shares'; } return implode(', ', $details); }
<tr> <td style='padding-bottom:.6em'> <?php echo entity_link($object, null); ?> </td> <td style='padding-bottom:.6em'> <?php $recipients = LsDoctrineQuery::create()->from('Entity e')->andWhereIn('e.id', explode(',', $object['degree1_ids']))->fetchArray(); ?> <?php echo LsNumber::makeReadable($object['total'], '$'); ?> </td> <td style='padding-bottom:.6em'> <?php $recipientLinks = array(); ?> <?php foreach ($recipients as $recipient) { ?> <?php $recipientLinks[] = entity_link($recipient, null, false); ?> <?php } ?> <?php echo implode(', ', $recipientLinks); ?> </td>
static function getDonationSummary($id, $options = array()) { $blank = array('person_recipients' => array(), 'org_recipients' => array(), 'donors' => array(), 'rep_amts' => array(), 'dem_amts' => array(), 'other_amts' => array(), 'total' => 0, 'rep_total' => 0, 'dem_total' => 0, 'other_total' => 0, 'cycles' => array()); if (!($start_cycle = @$options['start_cycle'])) { $start_cycle = '1990'; } if (!($end_cycle = @$options['end_cycle'])) { $end_cycle = '2012'; } if (!($ext = @$options['type'])) { $db = Doctrine_Manager::connection(); $sql = "SELECT primary_ext FROM entity WHERE id = ?"; $stmt = $db->execute($sql, array($id)); $ext = $stmt->fetch(PDO::FETCH_COLUMN); } if ($ext == 'Person') { $donations = self::getPersonDonationData($id, $start_cycle, $end_cycle); } else { if ($ext == 'Org') { $donations = self::getOrgDonationData($id, $start_cycle, $end_cycle); } else { if ($ext = 'Couple') { $donations = self::getCoupleDonationData($id, $start_cycle, $end_cycle); } else { return $blank; } } } if (count($donations) == 0) { return $blank; } $cycles = array_map('strval', range(1990, 2020, 2)); $filter = function ($ary) use($start_cycle, $end_cycle) { return $ary >= $start_cycle && $ary <= $end_cycle; }; $cycles = array_filter($cycles, $filter); $cycleAmts = $repAmts = $demAmts = $otherAmts = array_fill_keys($cycles, 0); $recipients = array('personData' => array(), 'orgData' => array()); $donors = array(); $total = 0; $repTotal = 0; $demTotal = 0; $otherTotal = 0; $numDonations = 0; $parties = array(12886 => 'D', 12901 => 'R'); $party = null; $entity_fec_map = array(); $fec_party_map = array(); $org_donations = array_filter($donations, function ($d) { return $d['recipient_ext'] == 'Org'; }); $org_ids = array_map(function ($d) { return $d['recipient_id']; }, $org_donations); $org_party_map = self::getOrgPartyMap($org_ids); foreach ($donations as $d) { if ($d['recipient_ext'] == 'Person') { $party = @$parties[$d['party_id']]; } else { $party = @$org_party_map[$d['recipient_id']]; } $amt = intval($d['amt']); if ($amt > 0) { $numDonations++; } $recipientType = strtolower($d['recipient_ext']) . 'Data'; if (!isset($recipients[$recipientType][$d['recipient_id']])) { $url = EntityTable::getUri(array('id' => $d['recipient_id'], 'name' => $d['recipient_name'], 'primary_ext' => $d['recipient_ext'])); $recipients[$recipientType][$d['recipient_id']] = array('name' => $d['recipient_name'], 'url' => $url, 'amount' => $amt, 'donor_count' => 1, 'party' => $party, 'donor_ids' => array($d['donor_id'])); } else { $recipients[$recipientType][$d['recipient_id']]['amount'] += $amt; if (!in_array($d['donor_id'], $recipients[$recipientType][$d['recipient_id']]['donor_ids'])) { $recipients[$recipientType][$d['recipient_id']]['donor_ids'][] = $d['donor_id']; $recipients[$recipientType][$d['recipient_id']]['donor_count']++; } } if (!isset($donors[$d['donor_id']])) { $url = EntityTable::getUri(array('id' => $d['donor_id'], 'name' => $d['donor_name'], 'primary_ext' => $d['donor_ext'])); $donors[$d['donor_id']] = array('name' => $d['donor_name'], 'url' => $url, 'amount' => $amt, 'recipient_count' => 1, 'recipient_ids' => array($d['recipient_id'])); } else { $donors[$d['donor_id']]['amount'] += $amt; if (!in_array($d['recipient_id'], $donors[$d['donor_id']]['recipient_ids'])) { $donors[$d['donor_id']]['recipient_ids'][] = $d['recipient_id']; $donors[$d['donor_id']]['recipient_count']++; } } $cycleAmts[$d['crp_cycle']] += $amt; $total += $amt; if ($party == 'D') { $demAmts[$d['crp_cycle']] += $amt; $demTotal += $amt; } else { if ($party == 'R') { $repAmts[$d['crp_cycle']] += $amt; $repTotal += $amt; } else { $otherAmts[$d['crp_cycle']] += $amt; $otherTotal += $amt; } } } $personRecipients = $recipients['personData']; $orgRecipients = $recipients['orgData']; $amountCompareDesc = function ($a, $b) { return $b['amount'] - $a['amount']; }; uasort($personRecipients, $amountCompareDesc); uasort($orgRecipients, $amountCompareDesc); uasort($donors, $amountCompareDesc); if ($numDonations > 0) { $avgDonation = $total / $numDonations; } if ($repTotal > 0 || $demTotal > 0) { $demPct = LsNumber::makeReadable($demTotal / ($repTotal + $demTotal) * 100, null, 1, "%"); $repPct = LsNumber::makeReadable($repTotal / ($repTotal + $demTotal) * 100, null, 1, "%"); } return array('person_recipients' => $personRecipients, 'org_recipients' => $orgRecipients, 'donors' => $donors, 'rep_amts' => $repAmts, 'dem_amts' => $demAmts, 'other_amts' => $otherAmts, 'total' => $total, 'rep_total' => $repTotal, 'dem_total' => $demTotal, 'other_total' => $otherTotal, 'cycles' => $cycles); }
<tr> <td> <?php echo entity_link($object, null); ?> </td> <td> <?php echo LsNumber::makeReadable($object['degree1_total'], '$'); ?> </td> <td> <?php $people = EntityTable::getMultipleById(explode(',', $object['degree1_ids'])); ?> <?php $people_links = array(); ?> <?php foreach ($people as $person) { ?> <?php $people_links[] = entity_link($person, null, false); ?> <?php } ?> <?php echo implode(', ', $people_links); ?>
<tr class="text_small hover<?php echo $shaded ? ' shaded' : ''; ?> "> <td><?php echo Dateable::convertForDisplay($object['start_date']); ?> </td> <td><?php echo LsNumber::makeReadable($object['amount'], '$'); ?> </td> <td> <?php $agencies = array(); ?> <?php foreach (LobbyFilingTable::getAgenciesQuery($object)->setHydrationMode(Doctrine::HYDRATE_ARRAY)->execute() as $agency) { ?> <?php $agencies[] = entity_link($agency, null); ?> <?php } ?> <?php echo implode('<br /> ', $agencies); ?> </td> <td>
function readable_number($num, $prefix = null) { return LsNumber::makeReadable($num, $prefix); }
<tr class="text_small hover<?php echo $shaded ? ' shaded' : ''; ?> "> <td><?php echo $object->getStartDateForDisplay(); ?> </td> <td><?php echo LsNumber::makeReadable($object->amount, '$'); ?> </td> <td><?php echo $object->fec_filing_id; ?> </td> <td> <?php if ($url = $object->getSourceUrl()) { ?> <?php echo link_to('Source', $url); ?> <?php } ?> </td> </tr>