コード例 #1
0
 protected function setOrdering($creditnoteid)
 {
     $i = 1;
     $positions = $this->getPositions($creditnoteid);
     foreach ($positions as $position) {
         if ($position->ordering != $i) {
             if (!isset($positionsDb)) {
                 $positionsDb = new Sales_Model_DbTable_Creditnotepos();
             }
             $positionsDb->sortPosition($position->id, $i);
         }
         ++$i;
     }
 }
コード例 #2
0
 protected function getPositions($id)
 {
     $positionsDb = new Sales_Model_DbTable_Creditnotepos();
     $positions = $positionsDb->fetchAll($positionsDb->select()->where('creditnoteid = ?', $id)->where('clientid = ?', $this->_user['clientid'])->order('ordering'));
     return $positions;
 }
コード例 #3
0
ファイル: InvoiceController.php プロジェクト: dewawi/dewawi
 public function generatecreditnoteAction()
 {
     $id = $this->_getParam('id', 0);
     $invoiceDb = new Sales_Model_DbTable_Invoice();
     $data = $invoiceDb->getInvoice($id);
     unset($data['id'], $data['invoiceid'], $data['invoicedate'], $data['ebayorderid']);
     $data['creditnotedate'] = '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'];
     $creditnote = new Sales_Model_DbTable_Creditnote();
     $creditnoteid = $creditnote->addCreditnote($data);
     $positions = $this->getPositions($id);
     $positionsCreditnoteDb = new Sales_Model_DbTable_Creditnotepos();
     foreach ($positions as $position) {
         $dataPosition = $position->toArray();
         $dataPosition['creditnoteid'] = $creditnoteid;
         $dataPosition['created'] = $this->_date;
         $dataPosition['createdby'] = $this->_user['id'];
         $dataPosition['modified'] = '0000-00-00';
         $dataPosition['modifiedby'] = 0;
         unset($dataPosition['id'], $dataPosition['invoiceid']);
         $positionsCreditnoteDb->addPosition($dataPosition);
     }
     $this->_flashMessenger->addMessage('MESSAGES_CREDIT_NOTE_SUCCESFULLY_GENERATED');
     $this->_helper->redirector->gotoSimple('edit', 'creditnote', null, array('id' => $creditnoteid));
 }