0
직원에게 필터를 적용하여 작업 표 테이블에 필터를 표시하려고합니다. 나를 도울 수 있도록 다른 코드가 필요한 경우 게시를 시작하겠습니다. 코드는 filter.ctp입니다CAKEPHP : 필터 문제
http://webdesign4.georgianc.on.ca/~100141468/comp2084/todo/employees
문제 :http://webdesign4.georgianc.on.ca/~100141468/comp2084/todo/timesheets/filter/19
<table>
<tr>
<th>ID</th><th>name</th><th>Hours</th><th>Employees</th><th>Edit</th>
</tr>
<? foreach($timesheets as $row): ?>
<tr><td>
<?=$row['Timesheet']['id']?>
</td><td>
<?=$row['Timesheet']['hours']?>
</td><td>
<a href="../../employees/view/<?=$row['employee']['name']?>"><?=$row['employee']['name']?></a>
</td><td>
<a href="edit/<?=$row['Timesheet']['id']?>">Edit</a>
</td></tr>
<? endforeach; ?>
</table>
<?
class TimesheetsController extends AppController {
var $name = 'Timesheets';
var $scaffold;
var $helpers = array('Number');
function add() {
//check if user loaded form for first time or had already loaded & is now posting
if ($this->request->is('post')) {
//save the data to the db
if ($this->Timesheet->save($this->request->data)) {
//Build message & add to session
$this->Session->setFlash('Timesheet has been saved');
//take user back to the index page
$this->redirect(array('action'=>'index'));
}
//else save did not work
else {
$this->Session->setFlash('Unable to add Timesheet');
}
}
//populate the Employee list
$this->loadModel('Employee');
$this->set('Employees',$this->Employee->find('list',array('order'=> array('Employee.name'))));
$this->set(compact('Employees'));
//populate the Employee list
$this->loadModel('Client');
$this->set('Clients',$this->Client->find('list',array('order'=> array('Client.name'))));
$this->set(compact('Clients'));
}
//create function to filter Timesheet list by selected Employee
function filter($Employee_id) {
$this->set('Timesheets',$this->Timesheet->findAllByEmployeeId($Employee_id));
}
//create function to filter Timesheet list by selected Employee
function filter2($Client_id) {
$this->set('Timesheets',$this->Timesheet->findAllByClientId($Client_id));
}
}
?>
사용하여 컨트롤러의 변수 $ 작업 표를 설정해야 할 수도 있습니다 , 내가 어디에 놓았는지 알아낼 수 있니? 나는 내가 이미 그것을 가지고 있다고 생각한다. –
오, 알 겠어 ... PHP 변수는 대소 문자를 구별합니다 ... 타임 쉬트를 설정하고 타임 쉬트를 사용하려고합니다 – pollirrata
그래서 대문자 또는 소문자 여야합니까? –