コード例 #1
0
ファイル: CreditNotes.php プロジェクト: kokkez/shineisp
 /**
  * Save all the data
  * 
  * 
  * @param array $data
  */
 public static function saveAll($id, $data)
 {
     // Set the new values
     if (is_numeric($id)) {
         $creditnote = self::find($id);
     } else {
         $creditnote = new CreditNotes();
     }
     $creditnote['creationdate'] = Shineisp_Commons_Utilities::formatDateIn($data['creationdate']);
     $creditnote['number'] = $data['number'];
     $creditnote['invoice_id'] = $data['invoice_id'];
     $creditnote['total_net'] = $data['total_net'];
     $creditnote['total_vat'] = $data['total_vat'];
     $creditnote['total'] = $data['total'];
     $creditnote['note'] = $data['note'];
     if ($creditnote->trySave()) {
         if (!empty($data['description']) && !empty($data['price'])) {
             $creditnoteitem = new CreditNotesItems();
             $creditnoteitem['creditnote_id'] = $creditnote['creditnote_id'];
             $creditnoteitem['quantity'] = $data['quantity'];
             $creditnoteitem['description'] = $data['description'];
             $creditnoteitem['price'] = $data['price'];
             $creditnoteitem['vat'] = $data['vat'];
             $creditnoteitem['total'] = $data['price'] + $data['vat'];
             $creditnoteitem->save();
         }
         self::updateTotals($creditnote['creditnote_id']);
     }
     return $creditnote['creditnote_id'];
 }
コード例 #2
0
 /**
  * Delete the file attached
  */
 public function deleteitemAction()
 {
     $creditnote = CreditNotesItems::get_all($this->getRequest()->getParam('id'));
     if (!empty($creditnote)) {
         CreditNotesItems::DeleteByID($creditnote['creditnoteitem_id']);
         CreditNotes::updateTotals($creditnote['creditnote_id']);
         $this->_helper->redirector('edit', 'creditnotes', 'admin', array('id' => $creditnote['creditnote_id'], 'mex' => $this->translator->translate('The task requested has been executed successfully.'), 'status' => 'success'));
     }
     return $this->_helper->redirector('list', 'creditnotes', 'admin');
 }