function show_transaction_new($template) { global $TPL; global $tflist; $transaction = new transaction(); $transaction->set_values(); // wipe clean $TPL["display"] = "display:none"; $TPL["tfList_dropdown"] = page::select_options($tflist, NULL, 500); $TPL["fromTfList_dropdown"] = page::select_options($tflist, NULL, 500); $TPL["transactionType_dropdown"] = page::select_options(transaction::get_transactionTypes()); $TPL["status_dropdown"] = page::select_options(transaction::get_transactionStatii()); $TPL["link"] = ""; include_template($template); }
$tf->set_id($transactionRepeat->get_value("tfID")); if ($tf->select() && !$tf->get_value("tfActive")) { $TPL["message_help"][] = "This expense is allocated to an inactive TF. It will not create transactions."; } $tf = new tf(); $tf->set_id($transactionRepeat->get_value("fromTfID")); if ($tf->select() && !$tf->get_value("tfActive")) { $TPL["message_help"][] = "This expense is sourced from an inactive TF. It will not create transactions."; } $m = new meta("currencyType"); $currencyOps = $m->get_assoc_array("currencyTypeID", "currencyTypeID"); $TPL["currencyTypeOptions"] = page::select_options($currencyOps, $transactionRepeat->get_value("currencyTypeID")); $TPL["tfOptions"] = page::select_options($q, $transactionRepeat->get_value("tfID")); $TPL["fromTfOptions"] = page::select_options($q, $transactionRepeat->get_value("fromTfID")); $TPL["basisOptions"] = page::select_options(array("weekly" => "weekly", "fortnightly" => "fortnightly", "monthly" => "monthly", "quarterly" => "quarterly", "yearly" => "yearly"), $transactionRepeat->get_value("paymentBasis")); $TPL["transactionTypeOptions"] = page::select_options(transaction::get_transactionTypes(), $transactionRepeat->get_value("transactionType")); if (is_object($transactionRepeat) && $transactionRepeat->get_id() && $current_user->have_role("admin")) { $TPL["adminButtons"] .= ' <select name="changeTransactionStatus"><option value="">Transaction Status<option value="approved">Approve<option value="rejected">Reject<option value="pending">Pending</select> '; } if (is_object($transactionRepeat) && $transactionRepeat->get_id() && $transactionRepeat->get_value("status") == "pending") { $TPL["message_help"][] = "This Repeating Expense will only create Transactions once its status is Approved."; } else { if (!$transactionRepeat->get_id()) { $TPL["message_help"][] = "Complete all the details and click the Save button to create an automatically Repeating Expense"; } } $transactionRepeat->get_value("status") and $TPL["statusLabel"] = " - " . ucwords($transactionRepeat->get_value("status")); $TPL["taxName"] = config::get_config_item("taxName"); $TPL["main_alloc_title"] = "Create Repeating Expense - " . APPLICATION_NAME;
function show_new_transaction($template) { global $timeSheet; global $TPL; global $db; global $percent_array; if ($timeSheet->get_value("status") == "invoiced" && $timeSheet->have_perm(PERM_TIME_INVOICE_TIMESHEETS)) { $tf = new tf(); $options = $tf->get_assoc_array("tfID", "tfName"); $TPL["tf_options"] = page::select_options($options, $none); $transactionType_options = transaction::get_transactionTypes(); $TPL["transactionType_options"] = page::select_options($transactionType_options); $status_options = array("pending" => "Pending", "approved" => "Approved", "rejected" => "Rejected"); $TPL["status_options"] = page::select_options($status_options); $TPL["transaction_timeSheetID"] = $timeSheet->get_id(); $TPL["transaction_transactionDate"] = date("Y-m-d"); $TPL["transaction_product"] = ""; $TPL["transaction_buttons"] = ' <button type="submit" name="transaction_save" value="1" class="save_button">Add<i class="icon-plus-sign"></i></button> '; $TPL["percent_dropdown"] = page::select_options($percent_array, $empty); include_template($template); } }
alloc_redirect($TPL["url_alloc_transaction"] . "transactionID=" . $transaction->get_id()); } } } else { if ($_POST["delete"]) { $transaction->delete(); alloc_redirect($TPL["url_alloc_transactionList"] . "tfID=" . $transaction->get_value("tfID")); } } $transaction->set_tpl_values(); $t = new meta("currencyType"); $currency_array = $t->get_assoc_array("currencyTypeID", "currencyTypeID"); $TPL["currencyOptions"] = page::select_options($currency_array, $transaction->get_value("currencyTypeID")); $TPL["product"] = page::htmlentities($transaction->get_value("product")); $TPL["statusOptions"] = page::select_options(array("pending" => "Pending", "rejected" => "Rejected", "approved" => "Approved"), $transaction->get_value("status")); $transactionTypes = transaction::get_transactionTypes(); $TPL["transactionTypeOptions"] = page::select_options($transactionTypes, $transaction->get_value("transactionType")); is_object($transaction) and $TPL["transactionTypeLink"] = $transaction->get_transaction_type_link(); $db = new db_alloc(); $tf = new tf(); $options = $tf->get_assoc_array("tfID", "tfName"); // Special cases for the current tfID and fromTfID $options = add_tf($transaction->get_value("tfID"), $options, "tfIDWarning", " (warning: the TF <b>%s</b> is currently inactive)"); $options = add_tf($transaction->get_value("fromTfID"), $options, "fromTfIDWarning", " (warning: the TF <b>%s</b> is currently inactive)"); $TPL["tfIDOptions"] = page::select_options($options, $transaction->get_value("tfID")); $TPL["fromTfIDOptions"] = page::select_options($options, $transaction->get_value("fromTfID")); $q = "SELECT projectID as value, projectName as label FROM project WHERE projectStatus = 'Current' ORDER BY projectName"; $TPL["projectIDOptions"] = page::select_options($q, $transaction->get_value("projectID")); $TPL["transactionModifiedUser"] = page::htmlentities(person::get_fullname($TPL["transactionModifiedUser"])); $TPL["transactionCreatedUser"] = page::htmlentities(person::get_fullname($TPL["transactionCreatedUser"])); $tf1 = new tf();
function get_pending_repeat_transaction_list() { global $TPL; $transactionTypes = transaction::get_transactionTypes(); $q = "SELECT * FROM transaction \n LEFT JOIN transactionRepeat on transactionRepeat.transactionRepeatID = transaction.transactionRepeatID \n WHERE transaction.transactionRepeatID IS NOT NULL AND transaction.status = 'pending'"; $db = new db_alloc(); $db->query($q); while ($row = $db->row()) { $transaction = new transaction(); $transaction->read_db_record($db); $transaction->set_values(); $transactionRepeat = new transactionRepeat(); $transactionRepeat->read_db_record($db); $transactionRepeat->set_values(); $row["transactionType"] = $transactionTypes[$transaction->get_value("transactionType")]; $row["formTotal"] = $db->f("amount"); $row["transactionModifiedTime"] = $transaction->get_value("transactionModifiedTime"); $row["transactionCreatedTime"] = $transaction->get_value("transactionCreatedTime"); $row["transactionCreatedUser"] = person::get_fullname($transaction->get_value("transactionCreatedUser")); $rows[] = $row; } return (array) $rows; }
function load_transaction_filter($_FORM) { global $TPL; $rtn["statusOptions"] = page::select_options(array("" => "", "pending" => "Pending", "approved" => "Approved", "rejected" => "Rejected"), $_FORM["status"]); $transactionTypeOptions = transaction::get_transactionTypes(); $rtn["transactionTypeOptions"] = page::select_options($transactionTypeOptions, $_FORM["transactionType"]); $rtn["startDate"] = $_FORM["startDate"]; $rtn["endDate"] = $_FORM["endDate"]; if ($_FORM["monthDate"]) { $rtn["startDate"] = format_date("Y-m-", $_FORM["monthDate"]) . "01"; $t = format_date("U", $_FORM["monthDate"]); $rtn["endDate"] = date("Y-m-d", mktime(1, 1, 1, date("m", $t) + 1, 1, date("Y", $t))); } $display_format = "M"; // Fiddle $_FORM["monthDate"]. It may be a real date (2010-11-23) so change the last 2 chars to "01". $_FORM["monthDate"] = substr_replace($_FORM["monthDate"], "01", 8); // If this month is January, go from last Feb to this Feb $m = date("m") + 1; $y = date("Y"); // jump back a year iff it's December now if ($m == 13) { $m = 1; } else { $y -= 1; } $label_monthDate = date($display_format); for ($j = 0; $j < 13; $j++) { $label = date($display_format, mktime(0, 0, 0, $m, 1, $y)); $monthDate = date("Y-m-d", mktime(0, 0, 0, $m, 1, $y)); $bold = false; if ($monthDate == format_date("Y-m-d", $_FORM["monthDate"])) { $bold = true; } $link = $TPL["url_alloc_transactionList"] . "tfID=" . $_FORM["tfID"] . "&monthDate=" . $monthDate . "&applyFilter=true"; $bold and $rtn["month_links"] .= "<b>"; $rtn["month_links"] .= $sp . "<a href=\"" . $link . "\">" . $label . "</a>"; $bold and $rtn["month_links"] .= "</b>"; $sp = " "; if ($m == 12) { $m = 1; $y += 1; } else { $m += 1; } } if ($_FORM["sortTransactions"] == "transactionSortDate") { $rtn["checked_transactionSortDate"] = " checked"; } else { $rtn["checked_transactionDate"] = " checked"; } $tf = new tf(); $options = $tf->get_assoc_array("tfID", "tfName"); $rtn["tfOptions"] = page::select_options($options, $_FORM["tfID"]); $rtn["fromTfOptions"] = page::select_options($options, $_FORM["fromTfID"]); $rtn["transactionID"] = $_FORM["transactionID"]; $rtn["expenseFormID"] = $_FORM["expenseFormID"]; $rtn["product"] = $_FORM["product"]; $rtn["amount"] = $_FORM["amount"]; return $rtn; }