Example #1
0
use Edoceo\Radix\Session;
$Invoice = new Invoice(intval($_GET['i']));
switch (strtolower($_POST['a'])) {
    case 'delete':
        $Invoice->delete();
        Session::flash('info', 'Invoice #' . $Invoice['id'] . ' was deleted');
        $this->redirect('/');
        break;
    case 'hawk':
        $Invoice->setFlag(Invoice::FLAG_HAWK);
        $Invoice->save();
        Session::flash('info', 'Hawk monitoring has been added to this invoice, reminders will be according to cron schedule');
        $this->redirect('/invoice/view?i=' . $Invoice['id']);
        break;
    case 'no hawk':
        $Invoice->delFlag(Invoice::FLAG_HAWK);
        $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) {