getAmount();
$beneficiaryId = $event->getBeneficiary()->getId();
if (!isset($this->beneficiaries[$beneficiaryId]))
$this->beneficiaries[$beneficiaryId] = $amount;
else
$this->beneficiaries[$beneficiaryId] += $amount;
foreach ($event->getContext() as $ctx) {
if (!isset($this->contexts[$ctx->getId()]))
$this->contexts[$ctx->getId()] = $amount;
else
$this->contexts[$ctx->getId()] += $amount;
}
$this->total += $amount;
}
public function getTotal() {
return $this->total;
}
public function getBeneficiaries() {
$result = array();
foreach ($this->beneficiaries as $i => $amount)
array_push($result, array(Beneficiary::Get($i), $amount));
usort($result, function($a, $b) { return $b[1] -$a[1]; });
return $result;
}
public function getContexts() {
$result = array();
foreach ($this->contexts as $i => $amount) {
array_push($result, array(Context::Get($i), $amount));
}
usort($result, function($a, $b) { return $b[1] -$a[1]; });
return $result;
}
private $beneficiaries = array();
private $contexts = array();
private $total = 0;
}
function printContext($ctx) {
$result = "
";
usort($ctx, function($a, $b) { return strcasecmp($a->getLabel(), $b->getLabel()); });
foreach ($ctx as $i) {
$label = $i->getLabel();
$result .= "- ${label}
";
}
$result .= "
";
return $result;
}
function printEvent($e, $totalAmount) {
$id = $e->getId();
$amount = $e->getAmount();
$date = $e->getPaymentDate()->format("d/m/Y");
$label = $e->getLabel();
$beneficiary = $e->getBeneficiary()->getLabel();
$context = printContext($e->getContext());
echo "| ${date} | ";
echo "${label} | ";
echo "${beneficiary} | ";
echo "${context} | ";
echo "${amount} | ";
echo "
|
";
$totalAmount->add($e);
}
$totalAmount = new Total();
?>
| Date | Label | Beneficiary | Context | Amount | Action |
| Total | getTotal(); ?> | |
| Beneficiary | Amount |
getBeneficiaries() as $i) {
echo "| " .$i[0]->getLabel() ." | " .$i[1] ." |
";
}
?>
| Context | Amount |
getContexts() as $i) {
echo "| " .$i[0]->getLabel() ." | " .$i[1] ." |
";
}
?>