Пример #1
0
function add_tf($tfID, $options, $warningKey, $warningValue)
{
    // add a tf to the array of options, if it's not already there
    global $TPL;
    if ($tfID && !array_key_exists($tfID, $options)) {
        $tf = new tf();
        $tf->set_id($tfID);
        $tf->select();
        $options[$tfID] = $tf->get_value("tfName");
        $TPL[$warningKey] = sprintf($warningValue, $tf->get_value("tfName"));
    }
    return $options;
}
Пример #2
0
function add_inactive_tf($tfID, $options)
{
    // add a tf to the array of options, if it's not already there
    global $TPL;
    if ($tfID && !array_key_exists($tfID, $options)) {
        $tf = new tf();
        $tf->set_id($tfID);
        $tf->select();
        $options[$tfID] = $tf->get_value("tfName");
    }
    return $options;
}
Пример #3
0
    if (have_entity_perm("tf", PERM_READ, $current_user, true)) {
        // Person can only read TF records that they own
        $q = prepare("SELECT tf.tfID AS value, tf.tfName AS label\n                  FROM tf, tfPerson \n                 WHERE tfPerson.personID=%d \n                   AND tf.tfID=tfPerson.tfID \n                   AND (tf.tfActive = 1 OR tf.tfID = %d OR tf.tfID = %d)\n              ORDER BY tfName", $current_user->get_id(), $transactionRepeat->get_value("tfID"), $transactionRepeat->get_value("fromTfID"));
    } else {
        alloc_error("No permissions to generate TF list");
    }
}
//special case for disabled TF. Include it in the list, but also add a warning message.
$tf = new tf();
$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") {
Пример #4
0
 public static function get_list($_FORM = array())
 {
     $current_user =& singleton("current_user");
     list($filter1, $filter2) = tf::get_list_filter($_FORM);
     if (is_array($filter1) && count($filter1)) {
         $f = " AND " . implode(" AND ", $filter1);
     }
     if (is_array($filter2) && count($filter2)) {
         $f2 = " AND " . implode(" AND ", $filter2);
     }
     $db = new db_alloc();
     $q = prepare("SELECT transaction.tfID as id, tf.tfName, transactionID, transaction.status,\n                         sum(amount * pow(10,-currencyType.numberToBasic) * exchangeRate) AS balance\n                    FROM transaction\n               LEFT JOIN currencyType ON currencyType.currencyTypeID = transaction.currencyTypeID\n               LEFT JOIN tf on transaction.tfID = tf.tfID\n                   WHERE 1 AND transaction.status != 'rejected' " . $f2 . "\n                GROUP BY transaction.status,transaction.tfID");
     $db->query($q);
     while ($row = $db->row()) {
         if ($row["status"] == "approved") {
             $adds[$row["id"]] = $row["balance"];
         } else {
             if ($row["status"] == "pending") {
                 $pending_adds[$row["id"]] = $row["balance"];
             }
         }
     }
     $q = prepare("SELECT transaction.fromTfID as id, tf.tfName, transactionID, transaction.status,\n                         sum(amount * pow(10,-currencyType.numberToBasic) * exchangeRate) AS balance\n                    FROM transaction\n               LEFT JOIN currencyType ON currencyType.currencyTypeID = transaction.currencyTypeID\n               LEFT JOIN tf on transaction.fromTfID = tf.tfID\n                   WHERE 1 AND transaction.status != 'rejected' " . $f2 . "\n                GROUP BY transaction.status,transaction.fromTfID");
     $db->query($q);
     while ($row = $db->row()) {
         if ($row["status"] == "approved") {
             $subs[$row["id"]] = $row["balance"];
         } else {
             if ($row["status"] == "pending") {
                 $pending_subs[$row["id"]] = $row["balance"];
             }
         }
     }
     $q = prepare("SELECT tf.* \n                    FROM tf \n               LEFT JOIN tfPerson ON tf.tfID = tfPerson.tfID \n                   WHERE 1 " . $f . "\n                GROUP BY tf.tfID \n                ORDER BY tf.tfName");
     $db->query($q);
     while ($row = $db->row()) {
         $tf = new tf();
         $tf->read_db_record($db);
         $tf->set_values();
         $total = $adds[$db->f("tfID")] - $subs[$db->f("tfID")];
         $pending_total = $pending_adds[$db->f("tfID")] - $pending_subs[$db->f("tfID")];
         if (have_entity_perm("transaction", PERM_READ, $current_user, $tf->is_owner())) {
             $row["tfBalance"] = page::money(config::get_config_item("currency"), $total, "%s%m %c");
             $row["tfBalancePending"] = page::money(config::get_config_item("currency"), $pending_total, "%s%m %c");
             $row["total"] = $total;
             $row["pending_total"] = $pending_total;
         } else {
             $row["tfBalance"] = "";
             $row["tfBalancePending"] = "";
             $row["total"] = "";
             $row["pending_total"] = "";
         }
         $nav_links = $tf->get_nav_links();
         $row["nav_links"] = implode(" ", $nav_links);
         $row["tfActive_label"] = "";
         $tf->get_value("tfActive") and $row["tfActive_label"] = "Y";
         $rows[$tf->get_id()] = $row;
     }
     return (array) $rows;
 }
Пример #5
0
}
$defaults = array("url_form_action" => $TPL["url_alloc_transactionList"], "form_name" => "transactionList_filter", "applyFilter" => $applyFilter, "tfID" => $tfID, "startDate" => $startDate, "endDate" => $endDate, "monthDate" => $monthDate);
if ($download) {
    $_FORM = transaction::load_form_data($defaults);
    $rtn = transaction::get_list($_FORM);
    $totals = $rtn["totals"];
    $rows = $rtn["rows"];
    $csv = transaction::arr_to_csv($rows);
    header('Content-Type: application/octet-stream');
    header("Content-Length: " . strlen($csv));
    header('Content-Disposition: attachment; filename="' . date("Ymd_His") . '.csv"');
    echo $csv;
    exit;
}
// Check perm of requested tf
$tf = new tf();
$tf->set_id($tfID);
$tf->select();
$TPL["tfID"] = $tfID;
$_FORM = transaction::load_form_data($defaults);
$rtn = transaction::get_list($_FORM);
$TPL["totals"] = $rtn["totals"];
$TPL["transactionListRows"] = $rtn["rows"];
// Total balance
$TPL["balance"] = $tf->get_balance();
// Total balance pending
$TPL["pending_amount"] = $tf->get_balance(array("status" => "pending"));
// Page and header title
$TPL["title"] = "Statement for tagged fund: " . $tf->get_value("tfName");
$TPL["main_alloc_title"] = "TF: " . $tf->get_value("tfName") . " - " . APPLICATION_NAME;
include_template("templates/transactionListM.tpl");
Пример #6
0
 }
 echo "<br>Attempting repeating transaction: " . $transactionRepeat->get_value("product") . " ... ";
 //echo '<br><br>$nextScheduled <= $today && $nextScheduled >= $startDate && $nextScheduled <= $finishDate';
 //echo "<br>".$nextScheduled." <= ".$today." && ".$nextScheduled." >= ".$startDate." && ".$nextScheduled." <= ".$finishDate;
 while ($nextScheduled <= $today && $nextScheduled >= $startDate && $nextScheduled <= $finishDate) {
     $tf = new tf();
     $tf->set_id($transactionRepeat->get_value("tfID"));
     $tf->select();
     if (!$tf->get_value("tfActive")) {
         echo "<br>Skipping because tf not active: " . $tf->get_value("tfName");
         continue 2;
     }
     $tf = new tf();
     $tf->set_id($transactionRepeat->get_value("fromTfID"));
     $tf->select();
     if (!$tf->get_value("tfActive")) {
         echo "<br>Skipping because tf not active: " . $tf->get_value("tfName");
         continue 2;
     }
     $amount = page::money_out($transactionRepeat->get_value("currencyTypeID"), $transactionRepeat->get_value("amount"));
     $transaction = new transaction();
     $transaction->set_value("fromTfID", $transactionRepeat->get_value("fromTfID"));
     $transaction->set_value("tfID", $transactionRepeat->get_value("tfID"));
     $transaction->set_value("companyDetails", $transactionRepeat->get_value("companyDetails"));
     $transaction->set_value("amount", $amount);
     $transaction->set_value("currencyTypeID", $transactionRepeat->get_value("currencyTypeID"));
     $transaction->set_value("product", $transactionRepeat->get_value("product"));
     $transaction->set_value("transactionType", $transactionRepeat->get_value("transactionType"));
     $transaction->set_value("status", "pending");
     $transaction->set_value("transactionRepeatID", $transactionRepeat->get_id());
     $transaction->set_value("transactionDate", date("Y-m-d", $nextScheduled));
Пример #7
0
$tf = new tf();
$tfID = $_GET["tfID"] or $tfID = $_POST["tfID"];
if ($tfID) {
    $tf->set_id($tfID);
    $tf->select();
} else {
    $tf_is_new = true;
}
if ($_POST["save"]) {
    $tf->read_globals();
    if ($_POST["isActive"]) {
        $tf->set_value("tfActive", 1);
    } else {
        $tf->set_value("tfActive", 0);
    }
    if ($tf->get_value("tfName") == "") {
        alloc_error("You must enter a name.");
    } else {
        if (!$tf->get_id()) {
            $db = new db_alloc();
            $q = prepare("SELECT count(*) AS tally FROM tf WHERE tfName = '%s'", $tf->get_value("tfName"));
            $db->query($q);
            $db->next_record();
            $tf_is_taken = $db->f("tally");
        }
        if ($tf_is_taken) {
            alloc_error("That TF name is taken, please choose another.");
        } else {
            $tf->set_value("tfComments", rtrim($tf->get_value("tfComments")));
            $tf->save();
            $TPL["message_good"][] = "Your TF has been saved.";