예제 #1
0
    public static function CreateSupplierProjectExpense($party, $scope, $amount, $account, $voucher, $description)
    {
        try {
            $datetime = new DateTime();
            $sql = 'INSERT INTO expense_vouchers (project_id, party_id, voucher_no, date, stamp, status) 
		VALUES (' . $scope . ', ' . $party . ', "' . $voucher . '", "' . $datetime->format('d/m/Y') . '", ' . $datetime->format('YmdHis') . ', 0)';
            DatabaseHandler::Execute($sql);
            $sql = 'SELECT * FROM expense_vouchers WHERE stamp = ' . $datetime->format('YmdHis');
            $res = DatabaseHandler::GetRow($sql);
            $voucher = new ExpenseVoucher($res['id'], $res['project_id'], $res['report_id'], $res['voucher_no'], 0, $res['date'], $res['stamp'], $res['status']);
            $voucher->addItem(ExpenseItem::Create($res['id'], $scope, $description, $account, $amount));
            return $voucher;
        } catch (Exception $e) {
            return false;
        }
    }
예제 #2
0
    public static function Create($projectId, $report, $charges)
    {
        try {
            $datetime = new DateTime();
            $sql = 'INSERT IGNORE INTO expense_vouchers (project_id, report_id, date, stamp, status) 
		VALUES (' . $projectId . ', ' . $report->id . ', "' . $datetime->format('d/m/Y') . '", ' . $datetime->format('YmdHis') . ', 0)';
            DatabaseHandler::Execute($sql);
            $sql = 'SELECT * FROM expense_vouchers WHERE stamp = ' . $datetime->format('YmdHis');
            $res = DatabaseHandler::GetRow($sql);
            $voucher = new ExpenseVoucher($res['id'], $res['project_id'], $res['report_id'], 0, $res['date'], $res['stamp'], $res['status']);
            foreach ($charges as $charge) {
                $voucher->addItem(ExpenseItem::Create($res['id'], $charge['claimant'], $charge['description'], $charge['category'], $charge['amount']));
            }
            return $voucher;
        } catch (Exception $e) {
        }
    }