public function applyAction() { $this->_helper->getHelper('layout')->setLayout('plain'); $request = $this->getRequest(); $locale = Zend_Registry::get('Zend_Locale'); $itemid = $this->_getParam('itemid', 0); $quoteid = $this->_getParam('quoteid', 0); $form = new Items_Form_Item(); if ($request->isPost()) { $this->_helper->viewRenderer->setNoRender(); $this->_helper->getHelper('layout')->disableLayout(); $data = array(); if ($itemid && $quoteid) { $item = new Items_Model_DbTable_Item(); $item = $item->getItem($itemid); $data['quoteid'] = $quoteid; $data['itemid'] = $itemid; $data['sku'] = $item['sku']; $data['title'] = $item['title']; $data['image'] = $item['image']; $data['description'] = $item['description']; $data['price'] = $item['price']; $data['taxrate'] = $item['taxid'] ? $this->_helper->TaxRate->getTaxRate($item['taxid']) : 0; $data['quantity'] = 1; $data['total'] = $data['price'] * $data['quantity']; $data['uom'] = $item['uomid'] ? $this->_helper->Uom->getUom($item['uomid']) : ''; $data['ordering'] = $this->getLatestOrdering($quoteid) + 1; $data['created'] = $this->_date; $data['createdby'] = $this->_user['id']; $data['clientid'] = $this->_user['clientid']; $position = new Sales_Model_DbTable_Quotepos(); $position->addPosition($data); //Calculate $this->_helper->Calculate($quoteid, $this->_currency, $this->_date, $this->_user['id']); } else { $form->populate($request->getPost()); } } else { if ($itemid > 0) { $item = new Items_Model_DbTable_Item(); $form->populate($item->getItem($itemid)); } } $this->view->form = $form; }
public function copyAction() { $this->_helper->viewRenderer->setNoRender(); $this->_helper->getHelper('layout')->disableLayout(); $id = $this->_getParam('id', 0); $item = new Items_Model_DbTable_Item(); $data = $item->getItem($id); unset($data['id']); $data['quantity'] = 0; $data['title'] = $data['title'] . ' 2'; $data['created'] = $this->_date; $data['createdby'] = $this->_user['id']; $data['modified'] = '0000-00-00'; $data['modifiedby'] = 0; echo $itemid = $item->addItem($data); $this->_flashMessenger->addMessage('MESSAGES_SUCCESFULLY_COPIED'); }