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) { } }
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; } }
public function processClaim($ledgerId, $voucherId, $items, $details) { if ($this->validateAdmin()) { $adj = ExpenseItem::Adjust($items); if ($adj) { $vouch = ExpenseVoucher::GetVoucher(intval($voucherId)); $tx = GeneralTransaction::PostClaim($ledgerId, $vouch->total, $vouch->items, $details); $claimslip = $tx->postprojectclaim($vouch); if ($claimslip) { $vouch->authorize($tx->transactionId); echo json_encode($claimslip); } else { echo 0; } } else { echo 0; } } else { echo 0; } }