Пример #1
0
     // Copy Invoice
     $I_Copy = new Invoice();
     foreach (array('contact_id', 'requester', 'kind', 'status', 'base_rate', 'base_unit', 'bill_address_id', 'ship_address_id', 'note') as $x) {
         $I_Copy[$x] = $Invoice[$x];
     }
     $I_Copy->setFlag(Invoice::FLAG_OPEN);
     $I_Copy->save();
     // Copy Invoice Items
     $list = $Invoice->getInvoiceItems();
     foreach ($list as $II_Orig) {
         $II_Copy = new InvoiceItem(null);
         $II_Copy['invoice_id'] = $I_Copy['id'];
         foreach (array('quantity', 'rate', 'unit', 'name', 'note', 'tax_rate') as $x) {
             $II_Copy[$x] = $II_Orig[$x];
         }
         $II_Copy->save();
     }
     Radix::redirect('/invoice/view?i=' . $I_Copy['id']);
     break;
 case 'paid':
     // New Transaction Holder
     $at = new \stdClass();
     $at->AccountJournalEntry = new AccountJournalEntry();
     $at->AccountJournalEntry['date'] = date('Y-m-d');
     $at->AccountJournalEntry['note'] = 'Payment for Invoice #' . $Invoice['id'];
     $at->AccountLedgerEntryList = array();
     // @todo Detect if should be Inbound Cash or Account Rx
     // @todo: Remove Account Hard Coding
     // This is the Cash Based Method :(
     //			// Inbound Cash
     //			$a = new Account( $_ENV['account']['inbound_account_id'] );
Пример #2
0
     Radix::redirect('/invoice/view?i=' . $ii['invoice_id']);
     break;
 case 'delete':
     $I = new Invoice($ii['invoice_id']);
     $I->delInvoiceItem($ii['id']);
     // $ii->delete();
     Session::flash('warn', sprintf('Invoice Item #%d was deleted', $ii['id']));
     Radix::redirect('/invoice/view?i=' . $I['id']);
     break;
 case 'save':
     $ii['invoice_id'] = intval($_POST['invoice_id']);
     foreach (array('kind', 'date', 'quantity', 'rate', 'unit', 'name', 'note', 'tax_rate') as $x) {
         $ii[$x] = trim($_POST[$x]);
     }
     // Save to DB
     $ii->save();
     Session::flash('info', sprintf('Invoice Item #%d saved', $ii['id']));
     // @todo Update the Balance (Sloppy, should be in IV->saveItem()
     $iv = new Invoice($_POST['invoice_id']);
     $iv->save();
     Radix::redirect('/invoice/view?i=' . $ii['invoice_id']);
     break;
     // case 'create':
 // case 'create':
 default:
     // Create
     // Create
     if (empty($_GET['id']) && !empty($_GET['i']) && intval($_GET['i']) > 0) {
         $this->title = array('Invoice', 'Item', 'Create');
         $this->Invoice = new Invoice(intval($_GET['i']));
         $this->InvoiceItem = new InvoiceItem(null);