我是cakephp的新手,但愿意为社区学习和贡献。
我有一个像这样的cakephp链接按钮:
<? echo $this->Html->link(__('Statement PDF'), array('action' => 'view_pdf','ext' => 'pdf', $person['Statement']['customerid']));?>
单击时会返回customerid的pdf。 在两个日期之间过滤后返回此页面的结果。 问题:如何使我的'Statement PDF'按钮返回与日期之间过滤时相同的结果?当我点击“Statement PDF”时,它会返回与customerid相关的所有结果。我正在使用dompdf来渲染我的pdf。
我的控制器代码:
public function view_pdf($id = NULL) {
if($this->request->is("post")) {
$filters = $this->request->data["search"];
$this->passedArgs["dateFrom"] = $filters["dateFrom"];
$this->passedArgs["dateTo"] = $filters["dateTo"];
// Assign search parameters:
$conditions["Statement.date >="] = $this->passedArgs["dateFrom"];
$conditions["Statement.date <="] = $this->passedArgs["dateTo"];
$conditions["Statement.customerid"] = $id;
}
else {
$conditions = array("customerid =" => $id);
}
$this->paginate = array(
'conditions' => $conditions,
'limit' => 5
);
ini_set('memory_limit', '800M');
$this->set("vary",$this->paginate("Statement"));
}
我的观点表单:
<?echo $this->Form->create('search', array('class' => false));
echo $this->Form->input('dateFrom');
echo $this->Form->input('dateTo');
echo $this->Form->submit('Search');
echo $this->Form->end();?>
我的观看代码:
<? foreach ($vary as $person):
<tr>
<td><?php echo $person['Statement']['date'];?></td>
<td><?php echo $person['Statement']['invoice_Number'];?></td>
<td ><?php echo "R\t".$this->Number->currency($person['Statement']['amount_Due'], $currency = " ");?></td>
<td ><?php echo "R\t".$this->Number->currency($person['Statement']['amount_Paid'], $currency = " ");?></td>
<td class ="actions">
<?// echo $this->Html->link('View as PDF', array('action'=>'viewinv', 'ext'=>'pdf', 1)); ?>
<? echo $this->Html->link(__('Statement PDF'), array('action' => 'view_pdf','ext' => 'pdf', $person['Statement']['customerid']));?>
</td>
</tr>
<? $total = $total + $person['Statement']['amount_Due'];
$amount = $amount + $person['Statement']['amount_Paid'];?>
<? endforeach;?> ?>
非常感谢你!