Example #1
0
 protected function setOrdering($quoteid)
 {
     $i = 1;
     $positions = $this->getPositions($quoteid);
     foreach ($positions as $position) {
         if ($position->ordering != $i) {
             if (!isset($positionsDb)) {
                 $positionsDb = new Sales_Model_DbTable_Quotepos();
             }
             $positionsDb->sortPosition($position->id, $i);
         }
         ++$i;
     }
 }
Example #2
0
 protected function getPositions($id)
 {
     $positionsDb = new Sales_Model_DbTable_Quotepos();
     $positions = $positionsDb->fetchAll($positionsDb->select()->where('quoteid = ?', $id)->where('clientid = ?', $this->_user['clientid'])->order('ordering'));
     return $positions;
 }
Example #3
0
 public function generatequoteAction()
 {
     $id = $this->_getParam('id', 0);
     $salesorderDb = new Sales_Model_DbTable_Salesorder();
     $data = $salesorderDb->getSalesorder($id);
     unset($data['id'], $data['salesorderid'], $data['salesorderdate']);
     $data['quotedate'] = '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'];
     $quote = new Sales_Model_DbTable_Quote();
     $quoteid = $quote->addQuote($data);
     $positions = $this->getPositions($id);
     $positionsQuoteDb = new Sales_Model_DbTable_Quotepos();
     foreach ($positions as $position) {
         $dataPosition = $position->toArray();
         $dataPosition['quoteid'] = $quoteid;
         $dataPosition['created'] = $this->_date;
         $dataPosition['createdby'] = $this->_user['id'];
         $dataPosition['modified'] = '0000-00-00';
         $dataPosition['modifiedby'] = 0;
         unset($dataPosition['id'], $dataPosition['salesorderid']);
         $positionsQuoteDb->addPosition($dataPosition);
     }
     $this->_flashMessenger->addMessage('MESSAGES_QUOTE_SUCCESFULLY_GENERATED');
     $this->_helper->redirector->gotoSimple('edit', 'quote', null, array('id' => $quoteid));
 }