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; }
$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."; $tf_is_new and $TPL["message_help"][] = "Please now add the TF Owners who are allowed to access this TF."; } }