我对贷方票据进行了一些复杂的计算,第一页是总金额的摘要。我不想做的是遍历所有规定以计算摘要,然后再次遍历它们以呈现详细视图。那么是否可以在添加详细视图后定义可以替换的自定义占位符?或者您是否知道另一种无需运行两次计算即可获得所需结果的方法?
编辑:
这就是我渲染详细视图的方式:
foreach($this->_creditNote->provisioningClient->customers as $customer)
{
$provisions = $customer->getProvisionsByBillingPeriodSum($this->_creditNote->billingPeriod);
if((count($provisions) >= 3 && $this->y > 230) || $this->y > 250)
{
$this->AddPage();
$this->SetFillColor(240);
$this->SetDrawColor(0);
$this->SetFont('Helvetica', 'B', 10);
$this->Cell(140, 6, 'Die Provisionen im Einzelnen', 'TB', 0, 'L', 1);
$this->Cell(30, 6, "Beträge", 'TB', 1, 'R', 1);
$this->SetXY(25, $this->y-11.5);
$this->SetTextColor(170,170,170);
$this->SetFont('Helvetica', '', 7);
$this->Cell(175, 6, 'Seite ' . $this->getAliasNumPage() . ' von ' . $this->getAliasNbPages(), '', 2, 'R');
$this->SetY($this->y+6);
$this->SetFont('Helvetica', '', 9);
$this->SetTextColor(0,0,0);
}
if(count($provisions) > 0)
{
$customerData = array();
$this->SetXY(20, $this->y+1);
$this->SetFont('Helvetica', 'B', 10);
$this->Cell(140, 0, $customer->contact->name . " (" . $customer->customerNumber . ")");
//add customer
$amount = 0;
$rows = array();
foreach($provisions as $provision)
{
$text = $provision->description;
$description = "";
if($provision->period != "onetime")
{
if($provision->isPartial($this->_creditNote->billingPeriod))
$text .= ", anteilig";
$description = $provision->periodName . ", " . $provision->getRuntime($this->_creditNote->billingPeriod);
}
if($description == "")
$description = null;
$temp = array($text, $provision->isPartial($this->_creditNote->billingPeriod) ? round($provision->getPartialAmount($this->_creditNote->billingPeriod)/100, 2) : $provision->amount / 100, $description);
$amount += $temp[1];
$rows[] = $temp;
}
$this->Cell(30, 0, number_format($amount, 2, ",", ".") . " €", 0, 1, 'R');
foreach($rows as $row)
{
$this->SetXY(23, $this->y+1);
$this->SetFont('Helvetica', '', 8);
$this->Cell(137, 0, $row[0]);
$this->Cell(30, 0, number_format($row[1], 2, ",", ".") . " €", 0, 1, 'R');
if($row[2])
{
$this->SetXY(26, $this->y + 1);
$this->SetFont('Helvetica', 'I', 8);
$this->MultiCell(140, 0, $row[2], 0, 'L');
}
}
}
}
提前致谢, 托拜厄斯