function save() { if (empty($this->_data['contact_id'])) { $this->_data['contact_id'] = null; } return parent::save(); }
/** Updates the path */ function save() { if (empty($this->_data['path'])) { $this->_data['path'] = $this->_savePath(); } $r = parent::save(); return $r; }
/** Saves the Note */ function save() { $this->_data['note'] = str_replace("\r\n", "\n", $this->_data['note']); $this->_data['note'] = utf8_decode($this->_data['note']); $this->_data['name'] = substr(strtok($this->_data['note'], "\n"), 0, 255); if (empty($this->_data['cts']) || strtotime($this->_data['cts']) <= 0) { $this->_data['cts'] = date('Y-m-d'); } return parent::save(); }
public function save() { if (empty($this->_data['auth_user_id'])) { $this->_data['auth_user_id'] = $_SESSION['uid']; } if (strtotime($this->_data['date']) == false) { $this->_data['date'] = null; } $this->_data['quantity'] = floatval($this['quantity']); $this->_data['rate'] = floatval($this['rate']); $this->_data['tax_rate'] = tax_rate_fix($this['tax_rate']); return parent::save(); }
/** Work Order Item Save */ function save() { if (empty($this->_data['auth_user_id'])) { $this->_data['auth_user_id'] = $_SESSION['uid']; } if (strtotime($this->_data['date']) == false) { $this->_data['date'] = null; } foreach (array('e_quantity', 'e_rate', 'e_tax_rate', 'a_quantity', 'a_rate', 'a_tax_rate') as $x) { if (empty($this->_data[$x])) { $this->_data[$x] = 0; } } $this->a_tax_rate = tax_rate_fix($this->a_tax_rate); $this->e_tax_rate = tax_rate_fix($this->e_tax_rate); parent::save(); }
/** @todo Should be Part of WorkOrder Class */ function wo2iv($id) { $wo = new WorkOrder($id); try { $iv = $wo->toInvoice(); } catch (Exception $e) { echo "EE " . $e . "\n"; return false; } echo "WO #{$wo->id} => IV #{$iv->id} for {${$iv->bill_amount}}\n"; // Post to their Account $C = new Contact($iv->contact_id); // Generate a Transaction to Post to This Clients Account Receivable $aje = new AccountJournalEntry(); $aje->date = $iv->date; $aje->note = 'Charge for Invoice #' . $iv->id; $aje->save(); // Debit Accounts Receivable for this Client $ale = new AccountLedgerEntry(); $ale->account_id = $_ENV['account']['receive_account_id']; $ale->account_journal_id = $aje->id; $ale->amount = abs($iv->bill_amount) * -1; $ale->link_to = ImperiumBase::getObjectType('contact'); $ale->link_id = $iv->contact_id; $ale->save(); // Credit Customer Account - or Revenue for Instant Revenue? // Old Query, Why from account by contact? $ale = new AccountLedgerEntry(); if ($C->account_id) { $ale->account_id = $C->account_id; } else { $ale->account_id = $_ENV['account']['revenue_account_id']; } $ale->account_journal_id = $aje->id; $ale->amount = abs($iv->bill_amount); $ale->link_to = ImperiumBase::getObjectType($iv); $ale->link_id = $iv->id; $ale->save(); echo "IV Posted {$aje->note} " . number_format($ale->amount, 2) . "\n"; // Send The Invoice via Email return $iv; }