2013-03-05 39 views
0

我有一個IT查詢系統是由用戶可以添加他們的查詢,當他們添加他們的查詢IT部門,然後對查詢的答覆/評論。更改表格字段使用2個不同的模型

應該如何工作,當用戶添加查詢時,必須將it_queries表中的query_type字段更改爲OPEN,並且IT部門查看查詢時,他們回覆/評論它,並且必須將query_type字段從OPEN更改爲PENDING那麼最終當用戶被幫助/協助時,他們應該能夠使用複選框將查詢標記爲關閉,然後將該狀態從「等待關閉」更改爲「關閉」。

不知道它們是否是在添加視圖中設置常量並在表中插入的方式。

顯然我正在學習,有人可以請我指導我必須採取的步驟。

這裏是我的代碼,添加it_query爲用戶

<?php echo $this->Form->create('ItQuery'); ?> 
<fieldset> 
<legend><?php echo __('Add It Query'); ?></legend> 
<?php 
echo $this->Form->hidden('hr_employee_id',array('value'=>$loggedInId)); 
echo $this->Form->input('it_query_type_id'); 
echo $this->Form->input('comment'); 
echo $this->Form->hidden('status_type', array('value'=>OPEN)); 
?> 
</fieldset> 
<?php echo $this->Form->end(__('Submit')); ?> 

這裏是我的IT評論代碼系

<?php echo $this->Form->create('ItQueryComment'); ?> 

<?php echo __('Add It Query Comment'); ?> 
<?php 
echo $this->Form->input('it_query_id'); 
echo $this->Form->input('comment'); 
echo $this->Form->input('close_query'); 
?> 

<?php echo $this->Form->end(__('Submit')); ?> 

這裏是我的ItQueryComments代碼

public function add() { 
if ($this->request->is('post')) { 
$this->ItQueryComment->create(); 
if ($this->ItQueryComment->save($this->request->data)) { 
$this->Session->setFlash(__('The it query comment has been saved')); 
$this->redirect(array('controller' => 'it_queries','action' => 'view', $this->request->data['ItQueryComment']['it_query_id'])); 
} else { 
$this->Session->setFlash(__('The it query comment could not be saved. Please, try again.')); 
} 
} 
$itQueries = $this->ItQueryComment->ItQuery->find('list'); 
$hrEmployees = $this->ItQueryComment->HrEmployee->find('list'); 
$this->set(compact('itQueries', 'hrEmployees')); 
} 

回答

0

在爲特定的Itquery保存評論時,在添加廣告後的評論控制器功能對數據庫的評論通過使用$ this-> getLastInsertID()獲取它的id; 併爲Itquery Model調用函數updateAll,並將該特定查詢的狀態更改爲「Pending」。

+0

我是cakephp的新手,我添加了控制器代碼。你能否突出顯示我必須更新代碼的位置? – 2013-03-07 13:48:24

相關問題