你好,我需要通过id找到我的报告的用户这是我的代码。 现在在我的代码的这一部分。
<?php echo $this->Html->link('soya existencia', array('controller' => 'Reportesoyaexistencias', 'action' => 'export_xls', $soyareporte['Soyareporte']['id'])); ?>
我设置了用户的id,因为只需要这个用户的报告。在我的索引中我只做一个链接,这个链接将我的id设置为reporteexistenciassoya我需要的地方只显示我发送的id和所有记录。这是所有代码:
SoyareportesController.php
index.ctp
<table>
<thead>
<tr>
<th><?php echo $this->Paginator->sort('username', 'Nombre de Usuario');?> </th>
<th><?php echo $this->Paginator->sort('nombre', 'Nombre (s)');?> </th>
<th><?php echo $this->Paginator->sort('apellido', 'Apellido (s)');?> </th>
<th><?php echo $this->Paginator->sort('email', 'Email');?></th>
<th><?php echo $this->Paginator->sort('Grupo.categoria', 'Categoria');?></th>
<th><?php echo $this->Paginator->sort('Grupo.subcategoria', 'Sub-Categoria');?></th>
<th><?php echo $this->Paginator->sort('Perfil.codigogeneral', 'Codigo General');?></th>
<th>Soya report</th>
</tr>
</thead>
<tbody>
<?php $count=0; ?>
<?php foreach ($soyareportes as $soyareporte): ?>
<?php $count ++;?>
<?php if($count % 2): echo '<tr>'; else: echo '<tr class="zebra">' ?>
<?php endif; ?>
<td style="text-align: center;"><?php echo $soyareporte['Soyareporte']['username']; ?></td>
<td style="text-align: center;"><?php echo $soyareporte['Soyareporte']['nombre']; ?></td>
<td style="text-align: center;"><?php echo $soyareporte['Soyareporte']['apellido']; ?></td>
<td style="text-align: center;"><?php echo $soyareporte['Soyareporte']['email']; ?></td>
<td style="text-align: center;"><?php echo $soyareporte['Grupo']['categoria']; ?></td>
<td style="text-align: center;"><?php echo $soyareporte['Grupo']['subcategoria']; ?></td>
<td style="text-align: center;"><?php echo $soyareporte['Perfil']['codigogeneral']; ?></td>
<td><?php echo $this->Html->link('soya existencia', array('controller' => 'Reportesoyaexistencias', 'action' => 'export_xls', $soyareporte['Soyareporte']['id'])); ?>
</td>
</tr>
<?php endforeach; ?>
<?php unset($soyarreporte); ?>
</tbody>
</table>
现在我的代码的这一部分。我接收值id,但是当我想显示valors时,所有值都是空的。
Reportesoyaexistencias.php
<?php
class ReportesoyaexistenciasController extends AppController {
var $name = 'Reportesoyaexistencias';
function export_xls($id = null) {
$this->loadModel("Reportesoyaexistencia");
//$this->Reportesoyaexistencia->recursive = 1;
$data = $this->Reportesoyaexistencia->findById($id);
if (!$this->request->data) {
$this->request->data = $data;
}
$this->set('soyaexistencias',$data);
//$this->render('export_xls','export_xls');
}
}
?>