Exemplo n.º 1
0
 /**
 	AccountJournalEntry save
 */
 function save()
 {
     if (strlen(trim($this->_data['note'])) == 0) {
         $this->_data['note'] = null;
     }
     return parent::save();
 }
Exemplo n.º 2
0
 function save()
 {
     if (empty($this->_data['contact_id'])) {
         throw new \Exception('CE#20: Invalid Contact ID');
     }
     return parent::save();
 }
Exemplo n.º 3
0
 /**
 	Invoice Model save()
 */
 function save()
 {
     if (empty($this->_data['auth_user_id'])) {
         $this->_data['auth_user_id'] = $_SESSION['uid'];
     }
     parent::save();
     $this->_updateBalance();
 }
Exemplo n.º 4
0
 /**
 	Save
 */
 function save()
 {
     $this->note = utf8_decode($this->note);
     if (empty($this->_data['auth_user_id'])) {
         $this->_data['auth_user_id'] = $_SESSION['uid'];
     }
     $x = parent::save();
     $this->_updateBalance();
     return $x;
 }
Exemplo n.º 5
0
 /**
 	Contact Model delete()
 
 	Removes this Contact and All Addresses, Channels, Work Orders and Invoices!
 	@todo Should block if the Contact has a WorkOrder or Invoice
 */
 function delete()
 {
     $id = intval($this->id);
     // Check Workorder
     $res = SQL::fetch_one('SELECT count(id) FROM workorder WHERE contact_id = ?', array($id));
     if ($res > 0) {
         throw new Exception("Cannot delete Contact who owns Work Orders");
     }
     // Check Invoice
     $res = SQL::fetch_one('SELECT count(id) FROM invoice WHERE contact_id = ?', array($id));
     if ($res > 0) {
         throw new Exception("Cannot delete Contact who owns Invoices");
     }
     SQL::query('DELETE FROM contact_address WHERE contact_id = ?', array($id));
     SQL::query('DELETE FROM contact_channel WHERE contact_id = ?', array($id));
     //$db->query("delete from workorder where contact_id = $id");
     //$this->WorkOrder->deleteAll("WorkOrder.contact_id=$id",false,false);
     //$db->query("delete from invoice where contact_id = $id");
     //$this->Invoice->deleteAll("Invoice.contact_id=$id",false,false);
     $x = parent::delete($id, true);
     return $x;
 }
Exemplo n.º 6
0
     $at->AccountLedgerEntryList[] = $ale;
     // Credit Customer Account - or Revenue for Instant Revenue?
     // Old Query, Why from account by contact?
     // $x = $this->_d->fetchRow('SELECT * FROM account WHERE contact_id = ?',array($c->id));
     // if ($x->id) {
     //	 $a = new Account($x->id);
     if ($C['account_id']) {
         $a = new Account($C['account_id']);
     } else {
         $a = new Account($_ENV['account']['revenue_account_id']);
     }
     $ale = new AccountLedgerEntry();
     $ale['account_id'] = $a['id'];
     $ale['account_name'] = $a['full_name'];
     $ale['amount'] = abs($Invoice['bill_amount']);
     $ale['link_to'] = ImperiumBase::getObjectType($Invoice);
     $ale['link_id'] = $Invoice['id'];
     $at->AccountLedgerEntryList[] = $ale;
     // @deprecated
     // $this->_s->AccountTransaction = $at;
     // $this->_s->ReturnTo = sprintf('/invoice/view?i=%d', $Invoice['id']);
     $_SESSION['account-transaction'] = $at;
     $_SESSION['return-path'] = sprintf('/invoice/view?i=%d', $Invoice['id']);
     Radix::redirect('/account/transaction');
     break;
     // Save the Updated Invoice
 // Save the Updated Invoice
 case 'save':
     // Save Request
     foreach (array('contact_id', 'date', 'kind', 'status', 'bill_address_id', 'ship_address_id', 'note') as $x) {
         $Invoice[$x] = trim($_POST[$x]);