本文整理匯總了PHP中Transaction::Init_transaction方法的典型用法代碼示例。如果您正苦於以下問題:PHP Transaction::Init_transaction方法的具體用法?PHP Transaction::Init_transaction怎麽用?PHP Transaction::Init_transaction使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Transaction
的用法示例。
在下文中一共展示了Transaction::Init_transaction方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: createSinkTransaction
function createSinkTransaction($ledgerEntries, $loginId, $txDate)
{
$txDateString = $txDate->format('m/d/Y');
$sinkTransaction = new Transaction();
$sinkTransaction->Init_transaction($loginId, "EOM auto-sink", $txDateString, $txDateString, '', NULL, NULL, NULL, NULL, 1, 0, 0, -1, 1, '', NULL, -1, -1, 0.0, $ledgerEntries, array());
return $sinkTransaction;
}
示例2: Get_transaction_list
public static function Get_transaction_list($account_id, $start_date, $end_date, $limit, $search_text, $total_period, &$error, &$warning)
{
$trans_list = array();
// VALIDATION
$error = '';
$start_time = parse_date($start_date);
$end_time = parse_date($end_date);
if ($start_time == -1) {
$error = 'Invalid start date';
} elseif ($end_time == -1) {
$error = 'Invalid end date';
} elseif ($limit < 0) {
$error = 'Limit must be 0 (no limit) or greater';
}
if ($error != '') {
//echo $error;
return $trans_list;
}
$sql = "SELECT account_debit, equation_side \n" . "FROM Accounts WHERE account_id = :account_id";
$account_debit = '';
$equation_side = '';
$pdo = db_connect_pdo();
$ps = $pdo->prepare($sql);
$ps->bindParam(':account_id', $account_id);
$t1 = microtime(true);
$success = $ps->execute();
$t2 = microtime(true);
if (!$success) {
echo get_pdo_error($ps);
return;
}
if ($row = $ps->fetch(PDO::FETCH_ASSOC)) {
$account_debit = $row['account_debit'];
$equation_side = $row['equation_side'];
} else {
return $trans_list;
}
//empty list
// Convert to mysql dates
$start_date_sql = convert_date($start_date, 1);
$end_date_sql = convert_date($end_date, 1);
$search_text_sql = '';
if ($search_text != '') {
// Search for a search string across several fields.
$search_text_sql = " and( t.trans_descr like '%{$search_text}%' " . " OR t.trans_vendor like '%{$search_text}%' " . "\tOR t.trans_comment like '%{$search_text}%' )\n";
}
/*
The ledger amount has to have the correct sign. If the ledger
entry is for an account with the same normal balance
(account debit) as the searched account, then it will be positive;
otherwise it will be negative.
The accounts are displayed by trans_date, but the totals
are calculated based on the accounting_date. This pulls up
any sub-accounts of the specified account. It is sorted in
reverse order so that the limit clause can be used for the most
recent dates.
*/
$sql = "SELECT t.trans_id, trans_descr, trans_date, accounting_date, " . " trans_vendor, trans_comment, check_number, gas_miles, " . " gas_gallons, trans_status, a.account_name, le.ledger_id, " . " aa.audit_id, aa.account_balance as audit_balance, " . " a2.account_name as account2_name, " . " a2.account_id as a2_account_id, a.account_id, " . " t.budget_date, t.exclude_from_budget, " . " (ledger_amount * a.account_debit * :account_debit) as amount \n" . "FROM Transactions t \n" . "inner join Ledger_Entries le on " . "\tle.trans_id = t.trans_id " . "inner join Accounts a on " . "\tle.account_id = a.account_id " . "left join Accounts a2 on " . "\ta.account_parent_id = a2.account_id \n" . "left join Account_Audits aa ON " . "\taa.ledger_id = le.ledger_id " . "\tAND a.account_id = :account_id \n" . "WHERE (a.account_id = :account_id " . " or a2.account_id = :account_id " . " or a2.account_parent_id = :account_id ) " . " and accounting_date >= :start_date_sql " . " and accounting_date <= :end_date_sql \n" . $search_text_sql . "ORDER BY accounting_date DESC, t.trans_id DESC, le.ledger_id DESC \n";
if ($limit > 0) {
$sql .= "limit {$limit} ";
}
$ps = $pdo->prepare($sql);
$ps->bindParam(':account_debit', $account_debit);
$ps->bindParam(':account_id', $account_id);
$ps->bindParam(':start_date_sql', $start_date_sql);
$ps->bindParam(':end_date_sql', $end_date_sql);
$t3 = microtime(true);
$success = $ps->execute();
$t4 = microtime(true);
global $execTime, $readTime;
$execTime += $t2 - $t1 + $t4 - $t3;
if (!$success) {
echo get_pdo_error($ps);
return;
}
// Iterate through all the transactions
$i = 0;
while ($row = $ps->fetch(PDO::FETCH_ASSOC)) {
$account_display = $row['account_name'];
if (!is_null($row['account2_name']) && $row['a2_account_id'] != $account_id && $row['account_id'] != $account_id) {
// there is a parent account which is not
// the currently selected one; display it.
$account_display = $row['account2_name'] . ':' . $account_display;
}
$accountingTime = strtotime($row['accounting_date']);
$budgetTime = strtotime($row['budget_date']);
$priorMonth = 0;
if ($budgetTime < $accountingTime) {
$priorMonth = 1;
}
$trans = new Transaction();
$trans->Init_transaction($_SESSION['login_id'], $row['trans_descr'], convert_date($row['trans_date'], 2), convert_date($row['accounting_date'], 2), $row['trans_vendor'], $row['trans_comment'], $row['check_number'], $row['gas_miles'], $row['gas_gallons'], $row['trans_status'], $priorMonth, $row['exclude_from_budget'], $row['trans_id'], 1, $account_display, $row['amount'], $row['ledger_id'], $row['audit_id'], $row['audit_balance']);
$trans_list[$i] = $trans;
$i++;
$MAX_ROWS = 1000;
if ($i > $MAX_ROWS) {
// Avoid memory errors
$warning = "Warning: truncated data to {$MAX_ROWS} rows";
break;
//.........這裏部分代碼省略.........
示例3: Transaction
$ledger->setAccountData($_POST['accountR_id'][$i]);
$ledger->amount = $_POST['amountR'][$i];
$ledgerR_list[] = $ledger;
}
}
//nl2br (print_r ($ledgerL_list));
//nl2br (print_r ($ledgerR_list));
$excludeBudget = 0;
$priorMonth = 0;
if (isset($_POST['prior_month'])) {
$priorMonth = 1;
}
if (isset($_POST['exclude_budget'])) {
$excludeBudget = 1;
}
$trans->Init_transaction($_SESSION['login_id'], $_POST['trans_descr'], $_POST['trans_date'], $_POST['accounting_date'], $_POST['trans_vendor'], $_POST['trans_comment'], $_POST['check_number'], $_POST['gas_miles'], $_POST['gas_gallons'], $_POST['trans_status'], $priorMonth, $excludeBudget, $_POST['trans_id'], $_POST['repeat_count'], '', NULL, -1, -1, 0.0, $ledgerL_list, $ledgerR_list);
$error = $trans->Validate();
if ($error == '') {
if ($mode == 'save') {
$error = $trans->Save_repeat_transactions();
} else {
$error = $trans->Delete_transaction();
}
}
if ($error == '') {
//successful save; reset for a new transaction
$trans = new Transaction();
}
}
$error1 = $error;
$warning = '';