2013-03-05 61 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

相关问题