示例#1
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;
 }
示例#2
0
文件: tf.php 项目: cjbayliss/alloc
        exit;
    }
}
if ($_POST["person_save"] || $_POST["person_delete"]) {
    $tfPerson = new tfPerson();
    $tfPerson->read_globals();
    $tfPerson->read_globals("person_");
    if (!$_POST["person_personID"]) {
        alloc_error("Please select a person from the dropdown list.");
    } else {
        if ($_POST["person_save"]) {
            $tfPerson->save();
            $TPL["message_good"][] = "Person added to TF.";
        } else {
            if ($_POST["person_delete"]) {
                $tfPerson->delete();
            }
        }
    }
}
$tf->set_values();
$TPL["tfModifiedTime"] = $tf->get_value("tfModifiedTime");
if ($tf->get_value("tfModifiedUser")) {
    $TPL["tfModifiedUser"] = person::get_fullname($tf->get_value("tfModifiedUser"));
}
$tf->get_value("tfActive") || !$tf->get_id() and $TPL["tfIsActive"] = " checked";
$TPL["main_alloc_title"] = "Edit TF - " . APPLICATION_NAME;
if (!$tf->get_id()) {
    $TPL["message_help"][] = "Enter the details below and click the Save button to create a new Tagged Fund. \n                            <br><br>A Tagged Fund or TF, is like a sort of bank account within allocPSA. \n                            It contains transactions which track the transfer of monies.";
}
include_template("templates/tfM.tpl");