예제 #1
0
<?php

/**
	Save Work Order
*/
namespace Edoceo\Imperium;

use Edoceo\Radix;
use Edoceo\Radix\Session;
use Edoceo\Imperium\Auth\Hash;
$id = intval($_GET['w']);
$wo = new WorkOrder($id);
switch (strtolower($_POST['a'])) {
    case 'bill':
        Radix::redirect('/workorder/invoice?w=' . $id);
        // $this->invoiceAction();
        // $this->_billAction();
        break;
    case 'close':
        $sql = "UPDATE workorder_item SET status = 'COMPLETE' ";
        $sql .= sprintf('WHERE workorder_id = %d', $wo->id);
        $this->_d->query($sql);
        $wo->status = 'Closed';
        $wo->save();
        Session::flash('info', "Work Order #{$id} Closed");
        Radix::redirect(sprintf('/workorder/view?w=%d', $wo->id));
    case 'delete':
        $wo->delete();
        Session::flash('info', "Work Order #{$id} was deleted");
        Radix::redirect('/workorder');
        break;
예제 #2
0
     if ($_ENV['aorkorder']['notify_send']) {
         $c = new Contact($this->WorkOrder['contact_id']);
         $this->WorkOrderItem['notify'] = $c->email;
     }
     break;
 case 'delete':
     $woi = new WorkOrderItem(intval($_GET['id']));
     $wo = new WorkOrder($woi['workorder_id']);
     $wo->delWorkOrderItem($woi['id']);
     Session::flash('info', "Work Order Item {$this->WorkOrderItem['id']} deleted");
     Radix::redirect('/workorder/view?w=' . $wo['id']);
     break;
 case 'save':
     $id = intval($_GET['id']);
     // Save Request
     $wo = new WorkOrder($_POST['workorder_id']);
     $woi = new WorkOrderItem($id);
     $set = array('kind', 'date', 'time_alpha', 'time_omega', 'e_rate', 'e_quantity', 'e_unit', 'e_tax_rate', 'a_rate', 'a_quantity', 'a_unit', 'a_tax_rate', 'name', 'note', 'status');
     // ,'notify' ? Gone?
     foreach ($set as $x) {
         $woi[$x] = trim($_POST[$x]);
     }
     $woi = $wo->addWorkOrderItem($woi);
     // Save to DB
     if ($id) {
         Session::flash('info', "Work Order Item #{$id} saved");
     } else {
         $id = $woi['id'];
         Session::flash('info', "Work Order Item #{$id} created");
     }
     // $wo->save();
예제 #3
0
<?php

/**
	@file
	@brief Convert WorkOrder to Invoice
*/
namespace Edoceo\Imperium;

use Edoceo\Radix;
use Edoceo\Radix\Session;
use Edoceo\Radix\DB\SQL;
$wo = new WorkOrder(intval($_GET['w']));
$_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;