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 ($_POST["delete"] && $transactionRepeatID) {
        $transactionRepeat->set_id($transactionRepeatID);
        $transactionRepeat->delete();
        alloc_redirect($TPL["url_alloc_transactionRepeatList"] . "tfID=" . $_POST["tfID"]);
    }
    $_POST["product"] or alloc_error("Please enter a Product");
    $_POST["amount"] or alloc_error("Please enter an Amount");
    $_POST["fromTfID"] or alloc_error("Please select a Source TF");
    $_POST["tfID"] or alloc_error("Please select a Destination TF");
    $_POST["companyDetails"] or alloc_error("Please provide Company Details");
    $_POST["transactionType"] or alloc_error("Please select a Transaction Type");
    $_POST["transactionStartDate"] or alloc_error("You must enter the Start date in the format yyyy-mm-dd");
    $_POST["transactionFinishDate"] or alloc_error("You must enter the Finish date in the format yyyy-mm-dd");
    if (!$TPL["message"]) {
        !$transactionRepeat->get_value("status") && $transactionRepeat->set_value("status", "pending");
        $transactionRepeat->set_value("companyDetails", rtrim($transactionRepeat->get_value("companyDetails")));
        $transactionRepeat->save();
        alloc_redirect($TPL["url_alloc_transactionRepeat"] . "transactionRepeatID=" . $transactionRepeat->get_id());
    }
    $transactionRepeat->set_values();
}
$TPL["reimbursementRequired_checked"] = $transactionRepeat->get_value("reimbursementRequired") ? " checked" : "";
if ($transactionRepeat->get_value("transactionRepeatModifiedUser")) {
    $db->query("select username from person where personID=%d", $transactionRepeat->get_value("transactionRepeatModifiedUser"));
    $db->next_record();
    $TPL["user"] = $db->f("username");
}
if (have_entity_perm("tf", PERM_READ, $current_user, false)) {
    // Person can access all TF records
    $q = prepare("SELECT tfID AS value, tfName AS label \n                  FROM tf \n                 WHERE tfActive = 1 \n                    OR tf.tfID = %d \n                    OR tf.tfID = %d \n              ORDER BY tfName", $transactionRepeat->get_value("tfID"), $transactionRepeat->get_value("fromTfID"));
Ejemplo n.º 3
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;
    while ($nextScheduled <= $today && $nextScheduled >= $startDate && $nextScheduled <= $finishDate) {