Ejemplo n.º 1
0
function show_expenseFormList($template_name)
{
    global $db;
    global $TPL;
    global $transactionRepeat;
    $current_user =& singleton("current_user");
    $db = new db_alloc();
    $transactionRepeat = new transactionRepeat();
    if (!$_GET["tfID"] && !$current_user->have_role("admin")) {
        $tfIDs = $current_user->get_tfIDs();
        $tfIDs and $sql = prepare("WHERE tfID in (%s)", $tfIDs);
    } else {
        if ($_GET["tfID"]) {
            $sql = prepare("WHERE tfID = %d", $_GET["tfID"]);
        }
    }
    $db->query("select * FROM transactionRepeat " . $sql);
    while ($db->next_record()) {
        $i++;
        $transactionRepeat->read_db_record($db);
        $transactionRepeat->set_values();
        $TPL["tfName"] = tf::get_name($transactionRepeat->get_value("tfID"));
        $TPL["fromTfName"] = tf::get_name($transactionRepeat->get_value("fromTfID"));
        include_template($template_name);
    }
    $TPL["tfID"] = $tfID;
}
Ejemplo n.º 2
0
    }
    if ($basis == "quarterly") {
        return mktime(0, 0, 0, date("m", $mostRecent) + 3, date("d", $mostRecent), date("Y", $mostRecent));
    }
    if ($basis == "yearly") {
        return mktime(0, 0, 0, date("m", $mostRecent), date("d", $mostRecent), date("Y", $mostRecent) + 1);
    }
}
$db = new db_alloc();
$dbMaxDate = new db_alloc();
$today = mktime(0, 0, 0, date("m"), date("d"), date("Y"));
echo "<br>" . date("Y-m-d") . "<br>";
$db->query("select * from transactionRepeat WHERE status = 'approved'");
while ($db->next_record()) {
    $transactionRepeat = new transactionRepeat();
    $transactionRepeat->read_db_record($db);
    $startDate = format_date("U", $transactionRepeat->get_value("transactionStartDate"));
    $finishDate = format_date("U", $transactionRepeat->get_value("transactionFinishDate"));
    $timeBasisString = $transactionRepeat->get_value("paymentBasis");
    $query = prepare("SELECT max(transactionDate) AS latestDate FROM transaction WHERE transactionRepeatID=%d", $transactionRepeat->get_id());
    $dbMaxDate->query($query);
    $dbMaxDate->next_record();
    if (!$dbMaxDate->f("latestDate")) {
        $nextScheduled = timeWarp($startDate, $timeBasisString);
    } else {
        $mostRecentTransactionDate = format_date("U", $dbMaxDate->f("latestDate"));
        $nextScheduled = timeWarp($mostRecentTransactionDate, $timeBasisString);
    }
    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;
Ejemplo n.º 3
0
 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;
 }