Exemplo n.º 1
0
 public function copyAction()
 {
     $id = $this->_getParam('id', 0);
     $salesorderDb = new Sales_Model_DbTable_Salesorder();
     $data = $salesorderDb->getSalesorder($id);
     $this->_helper->viewRenderer->setNoRender();
     $this->_helper->getHelper('layout')->disableLayout();
     unset($data['id'], $data['salesorderid']);
     $data['title'] = $data['title'] . ' 2';
     $data['salesorderdate'] = '0000-00-00';
     $data['state'] = 100;
     $data['created'] = $this->_date;
     $data['createdby'] = $this->_user['id'];
     $data['modified'] = '0000-00-00';
     $data['modifiedby'] = 0;
     $data['locked'] = 0;
     $data['clientid'] = $this->_user['clientid'];
     $salesorder = new Sales_Model_DbTable_Salesorder();
     echo $salesorderid = $salesorder->addSalesorder($data);
     $positions = $this->getPositions($id);
     $positionsDb = new Sales_Model_DbTable_Salesorderpos();
     foreach ($positions as $position) {
         $dataPosition = $position->toArray();
         $dataPosition['salesorderid'] = $salesorderid;
         $dataPosition['created'] = $this->_date;
         $dataPosition['createdby'] = $this->_user['id'];
         $dataPosition['modified'] = '0000-00-00';
         $dataPosition['modifiedby'] = 0;
         unset($dataPosition['id']);
         $positionsDb->addPosition($dataPosition);
     }
     $this->_flashMessenger->addMessage('MESSAGES_SUCCESFULLY_COPIED');
 }
Exemplo n.º 2
0
 public function generatesalesorderAction()
 {
     $id = $this->_getParam('id', 0);
     $quoteDb = new Sales_Model_DbTable_Quote();
     $data = $quoteDb->getQuote($id);
     unset($data['id'], $data['quoteid'], $data['quotedate']);
     $data['salesorderdate'] = '0000-00-00';
     $data['state'] = 100;
     $data['created'] = $this->_date;
     $data['createdby'] = $this->_user['id'];
     $data['modified'] = '0000-00-00';
     $data['modifiedby'] = 0;
     $data['clientid'] = $this->_user['clientid'];
     $salesorder = new Sales_Model_DbTable_Salesorder();
     $salesorderid = $salesorder->addSalesorder($data);
     $positions = $this->getPositions($id);
     $positionsSalesorderDb = new Sales_Model_DbTable_Salesorderpos();
     foreach ($positions as $position) {
         $dataPosition = $position->toArray();
         $dataPosition['salesorderid'] = $salesorderid;
         $dataPosition['created'] = $this->_date;
         $dataPosition['createdby'] = $this->_user['id'];
         $dataPosition['modified'] = '0000-00-00';
         $dataPosition['modifiedby'] = 0;
         unset($dataPosition['id'], $dataPosition['quoteid']);
         $positionsSalesorderDb->addPosition($dataPosition);
     }
     $this->_flashMessenger->addMessage('MESSAGES_SALES_ORDER_SUCCESFULLY_GENERATED');
     $this->_helper->redirector->gotoSimple('edit', 'salesorder', null, array('id' => $salesorderid));
 }
Exemplo n.º 3
0
 public function copyAction()
 {
     $this->_helper->viewRenderer->setNoRender();
     $this->_helper->getHelper('layout')->disableLayout();
     $request = $this->getRequest();
     if ($request->isPost()) {
         $id = (int) $this->_getParam('id', 0);
         $position = new Sales_Model_DbTable_Salesorderpos();
         $data = $position->getPosition($id);
         $orderings = $this->getOrdering($data['salesorderid']);
         foreach ($orderings as $ordering => $positionId) {
             if ($ordering > $data['ordering']) {
                 $position->updatePosition($positionId, array('ordering' => $ordering + 1));
             }
         }
         $data['ordering'] += 1;
         $data['created'] = $this->_date;
         $data['createdby'] = $this->_user['id'];
         $data['modified'] = '0000-00-00';
         $data['modifiedby'] = 0;
         unset($data['id']);
         $position->addPosition($data);
         //Calculate
         $this->_helper->Calculate($data['salesorderid'], $this->_currency, $this->_date, $this->_user['id']);
     }
 }