Exemplo n.º 1
0
     $Invoice->save();
     Session::flash('info', 'Hawk monitoring has been removed from this invoice');
     $this->redirect('/invoice/view?i=' . $Invoice['id']);
     break;
 case 'copy':
     // 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();
Exemplo n.º 2
0
<?php

/**
	InvoiceController itemAction

	View/Edit an Item
*/
namespace Edoceo\Imperium;

use Edoceo\Radix;
use Edoceo\Radix\Session;
$ii = new InvoiceItem(intval($_GET['id']));
switch (strtolower($_POST['a'])) {
    case 'cancel':
        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']));