以下是我的控制器文件,reports_controller.php:
<?php
class ReportsController extends AppController {
var $name = 'Reports';
var $uses = array(
'Subscriber',
'Financial',
'Finbill',
'Trend'
);
var $presetVars = array(
array(
'field' => 'posted',
'type' => 'value'
),
array(
'field' => 'end_of_business_date',
'type' => 'value'
),
array(
'field' => 'end_of_bill_date',
'type' => 'value'
),
array(
'field' => 'start_id',
'type' => 'value'
),
array(
'field' => 'end_id',
'type' => 'value'
),
array(
'field' => 'month_year',
'type' => 'value'
)
);
function index() {
$subscriber = $this->Subscriber->find('first', array(
'contain' => false,
'order' => array('posted' => 'desc')
));
$this->set(compact('subscriber'));
}
function financial_bill_day() {
$this->Prg->commonProcess('Finbill');
$searchConditions = $this->Finbill->parseCriteria($this->passedArgs);
$finbill = $this->Finbill->find('first', array(
'conditions' => $searchConditions,
'contain' => false,
'order' => array('end_of_bill_date' => 'desc')
));
$finbillList = $this->Finbill->find('list', array(
'contain' => false,
'fields' => array(
'end_of_bill_date',
'_end_of_bill_date'
),
'order' => array('end_of_bill_date' => 'desc')
));
$this->set(compact('finbill', 'finbillList'));
}
function financial_day_begin() {
$this->Prg->commonProcess('Financial');
$searchConditions = $this->Financial->parseCriteria($this->passedArgs);
$financial = $this->Financial->find('first', array(
'conditions' => $searchConditions,
'contain' => false,
'order' => array('end_of_business_date' => 'desc')
));
$financialList = $this->Financial->find('list', array(
'contain' => false,
'fields' => array(
'end_of_business_date',
'_end_of_business_date'
),
'order' => array('end_of_business_date' => 'desc')
));
$this->set(compact('financial','financialList'));
}
function financial_day() {
$this->financial_day_begin();
$this->financial_bill_day();
$this->set(compact('finbill','finbillList','financial','financialList'));
}
}
?>
以下是我的观点,financial_day.ctp:
<div class="panel">
<h2><?php echo sprintf(__("End of Business %s", true), $financial['Financial']['_end_of_business_date']); ?></h2>
<div class="panel-content">
<?php echo $this->element('reports/tabs'); ?>
<div id="search" class="form">
<?php
echo $this->Form->create('Finbill', array('url' => array(
'controller' => 'reports',
'action' => 'financial_day'
)));
echo $this->Form->input('end_of_bill_date', array(
'label' => __("Select Cycle", true),
'options' => $finbillList
));
echo $this->Form->end();
?>
</div>
<?php
$labels = array(
'billed_in_cycle'
);
echo $this->Html->tag('h3', __("Billed", true));
echo $this->DataTable->create(array('class' => 'vertical'));
foreach($labels as $key => $label) {
if(is_numeric($key)) {
$key = $label;
$label = Inflector::humanize($label);
}
echo $this->DataTable->createRow();
echo $this->DataTable->createHeader(__($label, true));
echo $this->DataTable->createCell(sprintf("$%s", number_format($finbill['Finbill'][$key], 2)), array('class' => 'value'));
echo $this->DataTable->endRow();
}
echo $this->DataTable->end();
?>
<div id="search" class="form">
<?php
echo $this->Form->create('Financial', array('url' => array(
'controller' => 'reports',
'action' => 'financial_day'
)));
echo $this->Form->input('end_of_business_date', array(
'label' => __("Select Day", true),
'options' => $financialList
));
echo $this->Form->end();
?>
</div>
<?php
$labels = array(
'billed_adjustments' => 'Adjustments'
);
echo $this->Html->tag('h3', __("Adjustments", true));
echo $this->DataTable->create(array('class' => 'vertical'));
foreach($labels as $key => $label) {
if(is_numeric($key)) {
$key = $label;
$label = Inflector::humanize($label);
}
echo $this->DataTable->createRow();
echo $this->DataTable->createHeader(__($label, true));
echo $this->DataTable->createCell(sprintf("$%s", number_format($financial['Financial'][$key], 2)), array('class' => 'value'));
echo $this->DataTable->endRow();
}
echo $this->DataTable->end();
$labels = array(
'payments',
'payment_reversals',
'payments_net' => 'Net Payments'
);
echo $this->Html->tag('h3', __("Payments", true));
echo $this->DataTable->create(array('class' => 'vertical'));
foreach($labels as $key => $label) {
if(is_numeric($key)) {
$key = $label;
$label = Inflector::humanize($label);
}
echo $this->DataTable->createRow();
echo $this->DataTable->createHeader(__($label, true));
echo $this->DataTable->createCell(sprintf("$%s", number_format($financial['Financial'][$key], 2)), array('class' => 'value'));
echo $this->DataTable->endRow();
}
echo $this->DataTable->end();
?>
</div>
</div>
<?php
$this->Html->script("reports/financial_day", array('inline' => false));
?>
正如您所看到的,我在这里创建了2个表单并输入表单列表框。
我的目的是在各个表单中选择输入时以表格形式提取数据。因此,我正在为两个表单调用操作“financial_day”,这反过来调用两个操作“financial_bill_day”用于填充第一个表单,而“financial_day_begin”用于第二个表单。
最初,正确填充值,即从表中填充列表框。
但是,当我尝试更改下拉列表中的值时,第一个表单更改不会导致任何内容,并且在第二个表单上选择不同的值会给我一个错误。
'选择周期'列表框更改不会导致任何更改,并且'选择日'会导致错误。我可以在这里粘贴屏幕,但我刚加入这里并且没有足够的声望点。 :(
另外,我尝试在2013年1月20日的“选择日期”列表框中选择的URL是:http://flash.localhost/financial_day/end_of_business_date:2013-01-20(以防它有助于调试)