Пример #1
0
            $body = str_replace('$wi_name', $woi['name'], $body);
            $body = str_replace('$wi_note', $woi['note'], $body);
            $body = str_replace('$wi_quantity_est', $woi['e_quantity'], $body);
            $body = str_replace('$wi_rate_est', $woi['e_rate'], $body);
            $body = str_replace('$wi_unit_est', $woi['e_unit'], $body);
            $body = str_replace('$wi_quantity', $woi['a_quantity'], $body);
            $body = str_replace('$wi_rate', $woi['a_rate'], $body);
            $body = str_replace('$wi_unit', $woi['a_unit'], $body);
            $body = str_replace('$wi_cost', sprintf('%0.4f', $woi['a_quantity'] * $woi['a_rate']), $body);
            $body = str_replace('$wi_status', $woi['status'], $body);
            $mail['body'] = $body;
            $_SESSION['mail-compose'] = $mail;
            // Want to Add This History
            $_SESSION['return-path'] = '/workorder/view?w=' . $wo['id'];
            Radix::redirect('/email/compose');
        }
        Radix::redirect('/workorder/view?w=' . $wo['id']);
        break;
    case 'view':
        $id = intval($_GET['id']);
        $woi = new WorkOrderItem($id);
        if (empty($woi['id'])) {
            Session::flash('fail', sprintf('Cannot find Work Order Item #%d', $id));
            return;
        }
        $this->WorkOrder = new WorkOrder($woi['workorder_id']);
        $this->WorkOrderItem = $woi;
        break;
    default:
        Radix::dump($_POST);
}
Пример #2
0
        // $this->_s->EmailComposeMessage->body.= "\n\nSincerely,\n";
        // $this->_s->EmailComposeMessage->body.= '  ' . $this->_c->Company->name . "\n\n";
        // $this->_s->EmailComposeMessage->body.= 'PS: The linked files are in Adobe PDF format. You must have Acrobat Reader (or other compatible software) installed to view these documents.';
        // $this->_s->ReturnTo = sprintf('/workorder/view/id/%d?sent=true',$wo->id);
        $this->_s->ReturnGood = sprintf('/workorder/view?w=%d?sent=good', $wo->id);
        $this->_s->ReturnFail = sprintf('/workorder/view?w=%d?sent=fail', $wo->id);
        Radix::redirect('/email/compose');
        break;
    case 'save':
        $list = array('contact_id', 'date', 'kind', 'base_rate', 'base_unit', 'requester', 'note');
        foreach ($list as $x) {
            $wo[$x] = trim($_POST[$x]);
        }
        $wo->save();
        if ($id) {
            Session::flash('info', "Work Order #{$id} saved");
        } else {
            $id = $wo['id'];
            Session::flash('info', "Work Order #{$id} created");
        }
        Radix::redirect('/workorder/view?w=' . $id);
        break;
    case 'void':
        $sql = 'UPDATE workorder_item SET status = ? WHERE workorder_id = ? AND status = ?';
        SQL::query($sql, array('Void', $wo->id, 'Pending'));
        $wo['status'] = 'Void';
        $wo->save();
        Session::flash('info', "Work Order #{$wo->id} voided");
        Radix::redirect('/');
        break;
}
Пример #3
0
        if ('data:image/jpeg;base64,' == substr($image, 0, 23)) {
            $b64 = substr($image, 22);
            // Radix::dump($b64);
            $jpg_data = base64_decode($b64);
            $dir = sprintf('%s/webroot/img/content/contact/%u', APP_ROOT, $this->Contact['id']);
            if (!is_dir($dir)) {
                mkdir($dir, 0755, true);
            }
            $jpg_file = sprintf('%s/0.jpg', $dir);
            $res = file_put_contents($jpg_file, $jpg_data);
            if (0 == $res) {
                Session::flash('fail', 'Unable to write the snapshot');
            }
        }
        if ('data:image/png;base64,' == substr($image, 0, 22)) {
            $b64 = substr($image, 22);
            Radix::dump($b64);
            $png_data = base64_decode($b64);
            $dir = sprintf('%s/webroot/img/content/contact/%u', APP_ROOT, $this->Contact['id']);
            if (!is_dir($dir)) {
                mkdir($dir, 0755, true);
            }
            $png_file = sprintf('%s/0.png', $dir);
            $res = file_put_contents($png_file, $png_data);
            if (0 == $res) {
                Session::flash('fail', 'Unable to write the snapshot');
            }
        }
        Session::flash('info', 'Capture Saved');
        Radix::redirect('/contact/view?c=' . $this->Contact['id']);
}
Пример #4
0
        // 	$this->_redirect('/account/transaction?id=' . $aje->id);
        // }
        if ('save-copy' == $_POST['a']) {
            // $_SESSION['account-transaction'] = $aje;
            // $_SESSION['account-transaction-list' = array();
            // ] = $ale;
            // // $_SESSION['new-transaction'] = $aje;
            Radix::redirect('/account/transaction');
        }
        // Redirect Back
        $ret = '/account/ledger';
        if (!empty($_SESSION['return-path'])) {
            $ret = $_SESSION['return-path'];
            unset($_SESSION['return-path']);
        }
        Radix::redirect($ret);
        break;
}
if ($id) {
    $this->AccountJournalEntry = new AccountJournalEntry($id);
    //
    //$this->_d->fetchRow("select * from account_journal where id = $id");
    //$sql = $this->_d->select();
    //$sql->from('general_ledger');
    //$sql->where('account_journal_id = ?', $id);
    //$sql->order(array('account_full_code','amount'));
    // $sql = $this->_d->select();
    // $sql->from(array('al'=>'account_ledger'));
    // $sql->join(array('a'=>'account'),'al.account_id = a.id',array('a.full_name as account_name'));
    // $sql->where('al.account_journal_id = ?', $id);
    // //$sql->order(array('al.amount asc','a.full_code'));
Пример #5
0
        break;
    case '~':
        // Promote to RegExp Search
        $q = '.*' . substr($q, 1) . '.*';
        break;
    default:
        // Check for ID Specific Queries
        switch (strtok(strtolower($q), ':')) {
            case 'co':
                Radix::redirect('/contact/view?c=' . strtok(':'));
            case 'iv':
                Radix::redirect('/invoice/view?i=' . strtok(':'));
            case 'je':
                Radix::redirect('/account/transaction?id=' . strtok(':'));
            case 'wo':
                Radix::redirect('/workorder/view?w=' . strtok(':'));
        }
}
// Last Check
if (strlen($q) == 0) {
    $_ENV['title'] = array('Search', 'No Term Submitted');
    _draw_rebuild_prompt();
    return 0;
}
$idx = 0;
// PostgreSQL Full Text Search
$sql = 'SELECT link_to,link_id,name, ';
$sql .= ' ts_headline(ft,plainto_tsquery(?)) as snip, ';
$sql .= ' ts_rank_cd(tv,plainto_tsquery(?)) as sort ';
$sql .= ' FROM full_text ';
$sql .= ' WHERE tv @@ plainto_tsquery(?) ';
Пример #6
0
        $ce = new Event();
        $ce['contact_id'] = $C['id'];
        $ce['cts'] = $_SERVER['REQUEST_TIME'];
        // Create Time
        $ce['xts'] = $_SERVER['REQUEST_TIME'] + 86400 * 4;
        // Alert Time
        $ce['name'] = 'Ping this Contact';
        $ce->save();
        Session::flash('info', 'Contact #' . $id . ' event added');
        Radix::redirect('/contact');
        break;
    case 'save':
        $C['auth_user_id'] = $_SESSION['uid'];
        $C['account_id'] = intval($_POST['account_id']);
        if (!empty($_POST['parent_id'])) {
            $C['parent_id'] = intval($_POST['parent_id']);
        }
        $C['kind'] = $_POST['kind'];
        $C['status'] = $_POST['status'];
        $C['contact'] = $_POST['contact'];
        $C['company'] = $_POST['company'];
        $C['title'] = $_POST['title'];
        $C['email'] = $_POST['email'];
        $C['phone'] = $_POST['phone'];
        $C['url'] = $_POST['url'];
        $C['tags'] = $_POST['tags'];
        $C->save();
        Session::flash('info', "Contact #{$C['id']} saved");
        Radix::redirect('/contact/view?c=' . $C['id']);
}
// Radix::dump($_POST);
Пример #7
0
<?php

/**
 */
namespace Edoceo\Imperium;

use Edoceo\Radix;
use Edoceo\Radix\Session;
Session::kill();
Radix::redirect('/auth/sign-in');
Пример #8
0
<?php

/**
 */
use Edoceo\Radix;
use Edoceo\Radix\Session;
use Edoceo\Imperium\Account;
$a = new Account($_POST['id']);
switch (strtolower($_POST['a'])) {
    case 'delete':
        $a->delete();
        Session::flash('info', "Account #{$a['id']} deleted");
        break;
    case 'save':
        $a['parent_id'] = $_POST['parent_id'];
        $a['account_tax_line_id'] = $_POST['account_tax_line_id'];
        $a['code'] = $_POST['code'];
        $a['kind'] = $_POST['kind'];
        $a['name'] = $_POST['name'];
        $a['bank_account'] = $_POST['bank_account'];
        $a['bank_routing'] = $_POST['bank_routing'];
        $a->save();
        Session::flash('info', "Account #{$a['id']} saved");
}
Radix::redirect('/account');
Пример #9
0
        // Create Time
        $ce['xts'] = $_SERVER['REQUEST_TIME'] + 86400 * 4;
        // Alert Time
        $ce['name'] = 'Ping this Contact';
        $ce->save();
        Session::flash('info', 'Contact #' . $id . ' Event Added');
        Radix::redirect('/contact');
        break;
    case 'save':
        $co['auth_user_id'] = $_SESSION['uid'];
        $co['account_id'] = intval($_POST['account_id']);
        $co['parent_id'] = null;
        $co['kind'] = $_POST['kind'];
        $co['status'] = $_POST['status'];
        $co['contact'] = $_POST['contact'];
        $co['company'] = $_POST['company'];
        $co['title'] = $_POST['title'];
        $co['email'] = $_POST['email'];
        $co['phone'] = $_POST['phone'];
        $co['url'] = $_POST['url'];
        $co['tags'] = $_POST['tags'];
        $co->save();
        if ($id) {
            Session::flash('info', "Contact #{$id} saved");
        } else {
            $id = $co['id'];
            Session::flash('info', "Contact #{$id} created");
        }
        Radix::redirect('/contact/view?c=' . $id);
}
Radix::dump($_POST);
Пример #10
0
$_ENV['title'] = array("WorkOrder #{$wo['id']}", 'Build Invoice');
switch (strtolower($_POST['cmd'])) {
    case 'invoice':
        // if ($wo->status != 'Active') {
        //     $this->_s->fail[] = 'Only Active WorkOrders may build an Invoice';
        //     $this->redirect('/workorder/view?w=' . $id);
        // }
        // $this->_d->beginTransaction();
        $iv = $wo->toInvoice($_POST['invoice_id']);
        $x = $iv->getInvoiceItems();
        $msg = sprintf('Invoice #%d created from Work Order #%d with %d items', $iv['id'], $wo['id'], count($x));
        // Base_Diff::note($wo,$this->_s->info);
        // Base_Diff::note($iv,$this->_s->info);
        Session::flash('info', $msg);
        // $this->_d->commit();
        Radix::redirect('/invoice/view?i=' . $iv['id']);
        break;
}
$this->WorkOrder = $wo;
$w = array('woi.status in (?)' => array('Active', 'Complete'));
$w = null;
$this->WorkOrderItemList = $wo->getWorkOrderItems($w);
$this->Contact = new Contact($wo['contact_id']);
$this->InvoiceList = array(0 => '- New -');
$sql = 'SELECT * FROM invoice WHERE contact_id = ? AND status = ?';
$arg = array($this->Contact['id'], 'Active');
$res = SQL::fetch_all($sql, $arg);
foreach ($res as $x) {
    $k = $x['id'];
    $v = 'Invoice #' . $x['id'];
    $v .= ' from ' . date('m/d/y', strtotime($x['date']));
Пример #11
0
     // $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);
         $this->InvoiceItem['invoice_id'] = $this->Invoice['id'];
         return 0;
     }
     // View
     $this->InvoiceItem = new InvoiceItem(intval($_GET['id']));
Пример #12
0
        $n['kind'] = $_POST['kind'];
        // Append on Conversation
        if ($n['kind'] == 'Conversation') {
            $data = trim($n['note']);
            $data .= "\n---\n# " . date('D \\t\\h\\e jS \\o\\f F Y \\a\\t H:i') . "\n";
            $data .= $_POST['note'];
            $n['note'] = trim($data);
        } else {
            $n['note'] = trim($_POST['note']);
        }
        $x = str_replace(array('<br>', '<br/>', '<br />'), "\n", $n['note']);
        $x = trim(strip_tags($x));
        $n['name'] = strtok($x, "\n");
        $n['link'] = $_POST['link'];
        $n->save();
        if ($id) {
            Session::flash('info', "Note #{$id} saved");
        } else {
            $id = $n['id'];
            Session::flash('info', "Note #{$id} created");
        }
        $back_page = '/note/view?id=' . $id;
}
// Redirect Out
if (!empty($n['link'])) {
    if (preg_match('/(contact|invoice|workorder):(\\d+)/', $n['link'], $m)) {
        $back_page = '/' . $m[1] . '/view?' . substr($m[1], 0, 1) . '=' . $m[2];
    }
}
Radix::redirect($back_page);