我有一个manage_returns_controller它有两个动作,add和index.It有一个产品下拉列表,一个股票下拉列表和添加按钮。我还有manage_products_controller包含一个现场股票。但是现在我想做以下< / p>
当我点击退货控制器的添加按钮,然后同时保存退货数据以及增加产品表中的库存。
继承人添加行动代码
function add($id = null)
{
/*$this->pageTitle = "Edit Exchange";*/
$storeval = $this->Store->find('all',array('conditions'=>array('is_deleted'=>0,'is_blocked'=>0)));
//$storeval=$this->Store->findByName();
$storevalas = array();
foreach($storeval as $storevall)
{
$storevalas[$storevall['Store']['id']] = $storevall['Store']['name'];
}
$this->set('stock_entry_option_store', $storevalas);
//$product_name = $this->Exchange->product->find('list');
$storevaldd = $this->Product->find('all',array('conditions'=>array('is_deleted'=>0,'is_blocked'=>0)));
//$storeval=$this->Store->findByName();
$product_name = array();
foreach($storevaldd as $storevall)
{
$product_name[$storevall['Product']['id']] = $storevall['Product']['name'];
}
$this->set('stock_entry_option_product',$product_name);
$this->Return->id = $id;
if(!empty($id)){
$button_name = "Update";
$msg_act = "updated";
$this->pageTitle = "Edit Return";
} else {
$button_name = "Add";
$msg_act = "added";
$this->pageTitle = "Add Return";
}
if (empty($this->data))
{
$this->data = $this->Return->read();
}
else
{
if ($this->Return->save($this->data))
{
$this->Session->setFlash(__('Return successfully '.$msg_act.'.',true),'default',array('class' => 'success'));
$this->redirect(array('controller'=>'ManageReturns','action' => 'index'));
}
}
$this->set('button_name',$button_name);
}